officefileapi-devexpress-dot-pdf-02086893.md
A document contained in a PDF file.
Namespace : DevExpress.Pdf
Assembly : DevExpress.Pdf.v25.2.Core.dll
NuGet Package : DevExpress.Pdf.Core
public class PdfDocument :
IPdfDocument
Public Class PdfDocument
Implements IPdfDocument
The following members return PdfDocument objects:
The PdfDocument class contains members that allow you to perform the following operations with a PDF document:
Use the PdfDocument.Pages properties to organize pages in a PDF file. Refer to the following article for more information: Organize Pages in PDF Documents
The code sample below copies a page from one PDF document to another.
View Example: How to copy a page from one document to another
using DevExpress.Pdf;
using (PdfDocumentProcessor source = new PdfDocumentProcessor())
{
source.LoadDocument("..\\..\\Document1.pdf");
using (PdfDocumentProcessor target = new PdfDocumentProcessor())
{
target.LoadDocument("..\\..\\Document2.pdf");
target.Document.Pages.Insert(3, source.Document.Pages[0]);
target.SaveDocument("..\\..\\Result.pdf");
}
}
Imports DevExpress.Pdf
Using source As New PdfDocumentProcessor()
source.LoadDocument("..\..\Document1.pdf")
Using target As New PdfDocumentProcessor()
target.LoadDocument("..\..\Document2.pdf")
target.Document.Pages.Insert(3, source.Document.Pages(0))
target.SaveDocument("..\..\Result.pdf")
End Using
End Using
The following properties indicate the document information:
The following properties indicate what permissions are applied to the document:
| Permission | Property |
|---|---|
| Printer Permissions | AllowPrinting |
| AllowHighQualityPrinting | |
| Data Extraction Permissions | AllowDataExtraction |
| AllowAccessibility | |
| Modification Restrictions | AllowModifying |
| AllowDocumentAssembling | |
| Interactivity Permissions | AllowAnnotationsAndFormsModifying |
| AllowFormsFilling |
The ViewerPreferences property allows you to access the view preferences.
The code sample below specifies the document’s view preferences:
using (PdfDocumentProcessor pdfDocumentProcessor = new PdfDocumentProcessor())
{
pdfDocumentProcessor.LoadDocument("Documents//Invoice.pdf");
PdfDocument document = pdfDocumentProcessor.Document;
PdfViewerPreferences preferences = new PdfViewerPreferences();
preferences.DisplayDocTitle = true;
preferences.HideMenubar = true;
preferences.FitWindow = true;
preferences.PrintNumCopies = 3;
document.ViewerPreferences = preferences;
}
Using pdfDocumentProcessor As New PdfDocumentProcessor()
pdfDocumentProcessor.LoadDocument("Documents//Invoice.pdf")
Dim document As PdfDocument = pdfDocumentProcessor.Document
Dim preferences As New PdfViewerPreferences()
preferences.DisplayDocTitle = True
preferences.HideMenubar = True
preferences.FitWindow = True
preferences.PrintNumCopies = 3
document.ViewerPreferences = preferences
End Using
Use the PageLayout property to specify the layout of the opened document.
Call the SetMetadata to embed XMP metadata in the document. Refer to the following article for more information: Embed XMP Metadata in a PDF Document
The code sample below loads metadata from a file and embeds it in the document:
using DevExpress.Pdf;
using DevExpress.Pdf.Xmp;
//...
using (PdfDocumentProcessor pdfDocumentProcessor = new PdfDocumentProcessor())
{
pdfDocumentProcessor.LoadDocument("Documents//Invoice.pdf");
PdfDocument document = pdfDocumentProcessor.Document;
XmpDocument metadata = new XmpDocument();
using (FileStream xmlStream = new FileStream("Documents//metadata.xml", FileMode.Open, FileAccess.Read))
{
metadata = XmpDocument.FromStream(xmlStream);
document.SetMetadata(metadata);
}
pdfDocumentProcessor.SaveDocument("Invoice_Upd.pdf");
}
Imports DevExpress.Pdf
Imports DevExpress.Pdf.Xmp
'...
Using pdfDocumentProcessor As New PdfDocumentProcessor()
pdfDocumentProcessor.LoadDocument("Documents//Invoice.pdf")
Dim document As PdfDocument = pdfDocumentProcessor.Document
Dim metadata As New XmpDocument()
Using xmlStream As New FileStream("Documents//metadata.xml", FileMode.Open, FileAccess.Read)
metadata = XmpDocument.FromStream(xmlStream)
document.SetMetadata(metadata)
End Using
pdfDocumentProcessor.SaveDocument("Invoice_Upd.pdf")
End Using
Use the PdfDocumentProcessor.DocumentFacade property to retrieve a document facade - a set of methods used to perform various operations on PDF document without access to its inner structure. The PdfDocumentFacade instance allows you to organize annotations, change form fields, and remove page content. Refer to the following articles for more information:
Object PdfDocument
See Also