cete.dynamicpdf.merger.pdfdocument
PdfDocument
- Namespace: ceTe.DynamicPDF.Merger
- Assemblies: DynamicPDF.NETFramework40.dll, DynamicPDF.NETStandard20.dll
Represents a PDF document for import.
public class PdfDocument
Public Class PdfDocument
Inheritance: Object → PdfDocument
Licensing
This class is a DynamicPDF Merger Standard Edition feature. One of the following licenses is required for non-evaluation usage:
- DynamicPDF Merger for .NET Standard Edition
- DynamicPDF Merger for .NET Professional Edition
- DynamicPDF Merger for .NET Enterprise Edition
- DynamicPDF Core Suite for .NET Professional Edition
- DynamicPDF Core Suite for .NET Enterprise Edition
Examples
The following example will first merge two entire PDF documents together, then will Append a selected page of a third PDF to the end.
Imports System
Imports ceTe.DynamicPDF
Imports ceTe.DynamicPDF.Merger
Module MyModule
Sub Main()
' Create two PDF document objects
Dim pdfA As PdfDocument = New PdfDocument("C:\ImportPDF.pdf")
' The owner's password is required to merge encrypted PDFs
Dim pdfB As PdfDocument = New PdfDocument("C:\EncryptedPDF.pdf", "owner")
' Merge the two documents
Dim MyDocument As MergeDocument = MergeDocument.Merge(pdfA, pdfB)
' Append an additional document
Dim pdfC As PdfDocument = New PdfDocument("C:\MyDocumentC.pdf")
MyDocument.Append(pdfC, 2, 1)
' Save the PDF
MyDocument.Draw("C:\MyDocument.pdf")
End Sub
End Module
using System;
using ceTe.DynamicPDF.Merger;
Public Class Example
{
public static void CreatePDF(string outputPath, string inputPathPdfA, string inputPathPdfB, string password, string inputPathPdfC, int startPage)
{
// Create two PDF document objects
PdfDocument pdfA = new PdfDocument(inputPathPdfA);
// The owner's password is required to merge encrypted PDFs
PdfDocument pdfB = new PdfDocument(inputPathPdfB, password);
// Merge the two documents
MergeDocument document = MergeDocument.Merge(pdfA, pdfB);
// Append an additional document
PdfDocument pdfC = new PdfDocument(inputPathPdfC);
document.Append(pdfC, startPage, 1);
// Save the PDF
document.Draw(outputPath);
}
}
Remarks
This class should be used when you will be referencing an existing PDF document more than once. Using a PDFDocument is more efficient than specifying a file path because the document will not need to be parsed again on each subsequent reference. This class is safe for multithreaded operations.
Constructors
PdfDocument(Byte[])
Initializes a new instance of the PdfDocument class.
public PdfDocument(Byte[] data)
Public Sub New (data As Byte())
Parameters
- data: Byte[]
A byte array containing the PDF document data.
Licensing
This class is a DynamicPDF Merger Standard Edition feature. One of the following licenses is required for non-evaluation usage:
- DynamicPDF Merger for .NET Standard Edition
- DynamicPDF Merger for .NET Professional Edition
- DynamicPDF Merger for .NET Enterprise Edition
- DynamicPDF Core Suite for .NET Professional Edition
- DynamicPDF Core Suite for .NET Enterprise Edition
Exceptions
The PDF file cannot be parsed because it is likely corrupt or invalid.
The PDF file cannot be read because it is encrypted and the owner password is incorrect or not supplied.
PdfDocument(Byte[], String)
Initializes a new instance of the PdfDocument class.
public PdfDocument(Byte[] data, string password)
Public Sub New (data As Byte(), password As String)
Parameters
- data: Byte[]
A byte array containing the PDF document data.
- password: String
Owner password of the encrypted PDF document.
Licensing
This class is a DynamicPDF Merger Standard Edition feature. One of the following licenses is required for non-evaluation usage:
- DynamicPDF Merger for .NET Standard Edition
- DynamicPDF Merger for .NET Professional Edition
- DynamicPDF Merger for .NET Enterprise Edition
- DynamicPDF Core Suite for .NET Professional Edition
- DynamicPDF Core Suite for .NET Enterprise Edition
Exceptions
The PDF file cannot be parsed because it is likely corrupt or invalid.
The PDF file cannot be read because it is encrypted and the owner password is incorrect or not supplied.
PdfDocument(Stream)
Initializes a new instance of the PdfDocument class.
public PdfDocument(Stream stream)
Public Sub New (stream As Stream)
Parameters
- stream: Stream
Stream object containing the PDF document data.
Licensing
This class is a DynamicPDF Merger Standard Edition feature. One of the following licenses is required for non-evaluation usage:
- DynamicPDF Merger for .NET Standard Edition
- DynamicPDF Merger for .NET Professional Edition
- DynamicPDF Merger for .NET Enterprise Edition
- DynamicPDF Core Suite for .NET Professional Edition
- DynamicPDF Core Suite for .NET Enterprise Edition
Exceptions
The PDF file cannot be parsed because it is likely corrupt or invalid.
The PDF file cannot be read because it is encrypted and the owner password is incorrect or not supplied.
PdfDocument(Stream, String)
Initializes a new instance of the PdfDocument class.
public PdfDocument(Stream stream, string password)
Public Sub New (stream As Stream, password As String)
Parameters
- stream: Stream
Stream object containing the PDF document data.
- password: String
Owner password of the encrypted PDF document.
Licensing
This class is a DynamicPDF Merger Standard Edition feature. One of the following licenses is required for non-evaluation usage:
- DynamicPDF Merger for .NET Standard Edition
- DynamicPDF Merger for .NET Professional Edition
- DynamicPDF Merger for .NET Enterprise Edition
- DynamicPDF Core Suite for .NET Professional Edition
- DynamicPDF Core Suite for .NET Enterprise Edition
Exceptions
The PDF file cannot be parsed because it is likely corrupt or invalid.
The PDF file cannot be read because it is encrypted and the owner password is incorrect or not supplied.
PdfDocument(String)
Initializes a new instance of the PdfDocument class.
public PdfDocument(string filePath)
Public Sub New (filePath As String)
Parameters
- filePath: String
Physical file path of the PDF document.
Licensing
This class is a DynamicPDF Merger Standard Edition feature. One of the following licenses is required for non-evaluation usage:
- DynamicPDF Merger for .NET Standard Edition
- DynamicPDF Merger for .NET Professional Edition
- DynamicPDF Merger for .NET Enterprise Edition
- DynamicPDF Core Suite for .NET Professional Edition
- DynamicPDF Core Suite for .NET Enterprise Edition
Exceptions
The PDF file cannot be parsed because it is likely corrupt or invalid.
The PDF file cannot be read because it is encrypted and the owner password is incorrect or not supplied.
PdfDocument(String, String)
Initializes a new instance of the PdfDocument class.
public PdfDocument(string filePath, string password)
Public Sub New (filePath As String, password As String)
Parameters
- filePath: String
Physical file path of the PDF document.
- password: String
Owner password of the encrypted PDF document.
Licensing
This class is a DynamicPDF Merger Standard Edition feature. One of the following licenses is required for non-evaluation usage:
- DynamicPDF Merger for .NET Standard Edition
- DynamicPDF Merger for .NET Professional Edition
- DynamicPDF Merger for .NET Enterprise Edition
- DynamicPDF Core Suite for .NET Professional Edition
- DynamicPDF Core Suite for .NET Enterprise Edition
Exceptions
The PDF file cannot be parsed because it is likely corrupt or invalid.
The PDF file cannot be read because it is encrypted and the owner password is incorrect or not supplied.
Properties
Author
Gets the author property of the PDF document.
public string Author { get; }
Public Property Author As String
Property Value
Licensing
This class is a DynamicPDF Merger Standard Edition feature. One of the following licenses is required for non-evaluation usage:
- DynamicPDF Merger for .NET Standard Edition
- DynamicPDF Merger for .NET Professional Edition
- DynamicPDF Merger for .NET Enterprise Edition
- DynamicPDF Core Suite for .NET Professional Edition
- DynamicPDF Core Suite for .NET Enterprise Edition
CollectionType
Gets a value indicating the collectionType of a Pdf document
public CollectionType CollectionType { get; set; }
Public Property CollectionType As CollectionType
Property Value
Creator
Gets the creator property of the PDF document.
public string Creator { get; }
Public Property Creator As String
Property Value
Licensing
This class is a DynamicPDF Merger Standard Edition feature. One of the following licenses is required for non-evaluation usage:
- DynamicPDF Merger for .NET Standard Edition
- DynamicPDF Merger for .NET Professional Edition
- DynamicPDF Merger for .NET Enterprise Edition
- DynamicPDF Core Suite for .NET Professional Edition
- DynamicPDF Core Suite for .NET Enterprise Edition
Form
Gets the AcroForm for the document.
public PdfForm Form { get; }
Public Property Form As PdfForm
Property Value
Licensing
This class is a DynamicPDF Merger Professional Edition feature. One of the following licenses is required for non-evaluation usage:
- DynamicPDF Merger for .NET Professional Edition
- DynamicPDF Merger for .NET Enterprise Edition
- DynamicPDF Core Suite for .NET Professional Edition
- DynamicPDF Core Suite for .NET Enterprise Edition
Keywords
Gets the keywords property of the PDF document.
public string Keywords { get; }
Public Property Keywords As String
Property Value
Licensing
This class is a DynamicPDF Merger Standard Edition feature. One of the following licenses is required for non-evaluation usage:
- DynamicPDF Merger for .NET Standard Edition
- DynamicPDF Merger for .NET Professional Edition
- DynamicPDF Merger for .NET Enterprise Edition
- DynamicPDF Core Suite for .NET Professional Edition
- DynamicPDF Core Suite for .NET Enterprise Edition
NeedsRendering
Get the Needs Rendering property of the PDF document.
public bool NeedsRendering { get; }
Public Property NeedsRendering As Boolean
Property Value
Outlines
Gets the outlines of the PDF document.
public PdfOutlineList Outlines { get; }
Public Property Outlines As PdfOutlineList
Property Value
Licensing
This class is a DynamicPDF Merger Standard Edition feature. One of the following licenses is required for non-evaluation usage:
- DynamicPDF Merger for .NET Standard Edition
- DynamicPDF Merger for .NET Professional Edition
- DynamicPDF Merger for .NET Enterprise Edition
- DynamicPDF Core Suite for .NET Professional Edition
- DynamicPDF Core Suite for .NET Enterprise Edition
Pages
Gets a collection of PDF pages for the document.
public PdfPageList Pages { get; }
Public Property Pages As PdfPageList
Property Value
Licensing
This class is a DynamicPDF Merger Standard Edition feature. One of the following licenses is required for non-evaluation usage:
- DynamicPDF Merger for .NET Standard Edition
- DynamicPDF Merger for .NET Professional Edition
- DynamicPDF Merger for .NET Enterprise Edition
- DynamicPDF Core Suite for .NET Professional Edition
- DynamicPDF Core Suite for .NET Enterprise Edition
Producer
Gets the producer property of the PDF document.
public string Producer { get; }
Public Property Producer As String
Property Value
Licensing
This class is a DynamicPDF Merger Standard Edition feature. One of the following licenses is required for non-evaluation usage:
- DynamicPDF Merger for .NET Standard Edition
- DynamicPDF Merger for .NET Professional Edition
- DynamicPDF Merger for .NET Enterprise Edition
- DynamicPDF Core Suite for .NET Professional Edition
- DynamicPDF Core Suite for .NET Enterprise Edition
SecurityInfo
Gets the security type of the PDF document.
public SecurityInfo SecurityInfo { get; }
Public Property SecurityInfo As SecurityInfo
Property Value
Signed
Gets the signed property of the PDF document (only available in version 10.27+).
public bool Signed { get; }
Public Property Signed As Boolean
Property Value
Remarks
This property is only available with version 10.27 and later.
Subject
Gets the subject property of the PDF document.
public string Subject { get; }
Public Property Subject As String
Property Value
Licensing
This class is a DynamicPDF Merger Standard Edition feature. One of the following licenses is required for non-evaluation usage:
- DynamicPDF Merger for .NET Standard Edition
- DynamicPDF Merger for .NET Professional Edition
- DynamicPDF Merger for .NET Enterprise Edition
- DynamicPDF Core Suite for .NET Professional Edition
- DynamicPDF Core Suite for .NET Enterprise Edition
Tagged
Gets the Taging property of the PDF document.
public bool Tagged { get; }
Public Property Tagged As Boolean
Property Value
Title
Gets the title property of the PDF document.
public string Title { get; }
Public Property Title As String
Property Value
Licensing
This class is a DynamicPDF Merger Standard Edition feature. One of the following licenses is required for non-evaluation usage:
- DynamicPDF Merger for .NET Standard Edition
- DynamicPDF Merger for .NET Professional Edition
- DynamicPDF Merger for .NET Enterprise Edition
- DynamicPDF Core Suite for .NET Professional Edition
- DynamicPDF Core Suite for .NET Enterprise Edition
XmpMetadata
Gets the xml metadata string.
public string XmpMetadata { get; }
Public Property XmpMetadata As String
Property Value
Methods
Attachments()
Retrieves the attachment files in the PDFDocument
public Attachment[] Attachments()
Function Attachments() As Attachment[]
Returns
Contains the list of attachment files present in a pdf
Equals(Object)
Determines whether the specified Object is equal to the current Object . (Inherited from Object)
public bool Equals(Object obj)
Function Equals(obj As Object) As Boolean
Parameters
- obj: Object
The Object to compare with the current Object .
Returns
true if the specified Object is equal to the current Object ; otherwise, false.
GetEncryptionInfo(Byte[])
Gets the security information of the given PDF document.
public static EncryptionInfo GetEncryptionInfo(Byte[] data)
Shared Function GetEncryptionInfo(data As Byte()) As EncryptionInfo
Parameters
- data: Byte[]
A byte array containing the PDF document data.
Returns
The security information of the given PDF document.
GetEncryptionInfo(String)
Gets the security information of the given PDF document.
public static EncryptionInfo GetEncryptionInfo(string filePath)
Shared Function GetEncryptionInfo(filePath As String) As EncryptionInfo
Parameters
- filePath: String
Physical file path of the PDF document.
Returns
The security information of the given PDF document.
GetHashCode()
Serves as a hash function for a particular type. (Inherited from Object)
public int GetHashCode()
Function GetHashCode() As Integer
Returns
A hash code for the current Object .
GetPage(Int32)
Gets a page by page number.
public PdfPage GetPage(int pageNumber)
Function GetPage(pageNumber As Integer) As PdfPage
Parameters
- pageNumber: Int32
The page number to retrieve.
Returns
A PdfPage object.
Licensing
This class is a DynamicPDF Merger Standard Edition feature. One of the following licenses is required for non-evaluation usage:
- DynamicPDF Merger for .NET Standard Edition
- DynamicPDF Merger for .NET Professional Edition
- DynamicPDF Merger for .NET Enterprise Edition
- DynamicPDF Core Suite for .NET Professional Edition
- DynamicPDF Core Suite for .NET Enterprise Edition
Remarks
The first page is 1.
GetText()
Gets the text in all the pages.
public string GetText()
Function GetText() As String
Returns
A string containing the text in all the pages.
Licensing
This method is a DynamicPDF Merger Professional Edition feature. One of the following licenses is required for non-evaluation usage:
- DynamicPDF Merger for .NET Professional Edition
- DynamicPDF Merger for .NET Enterprise Edition
- DynamicPDF Core Suite for .NET Professional Edition
- DynamicPDF Core Suite for .NET Enterprise Edition
Examples
The following example will extract the entire text in the given PDF documents.
Imports System
Imports ceTe.DynamicPDF
Imports ceTe.DynamicPDF.Merger
Module MyModule
Sub Main()
' Create PDF document object
Dim pdfA As PdfDocument = New PdfDocument( "C:\TimeMachine.pdf")
' Call GetText method from PDF document object to get the text from the document
Dim extractedText As String = pdfA.GetText()
End Sub
End Module
using System;
using ceTe.DynamicPDF.Merger;
Public Class Example
{
public static void GetText(string inputPath)
{
// Create PDF document object
PdfDocument pdfA = new PdfDocument(inputPath);
// Call GetText method from PDF document object to get the text from the document
string extractedText = pdfA.GetText();
}
}
Remarks
This method can be used to extract the text in the same order the pdf operators are loaded. Text extraction skips characters that are morethan 2 bytes. With some of the .Net runtimes (example: .Net Core 2.0), Text extraction will give the error "No data is available for encoding 1252. For information on defining a custom encoding, see the documentation for the Encoding.RegisterProvider method.". To resolve this error refer the user manual page Encoding Considerations.
GetType()
Gets the Type of the current instance. (Inherited from Object)
public Type GetType()
Function GetType() As Type
Returns
The Type instance that represents the exact runtime type of the current instance.
SetDocumentInfo(Document)
Sets the document info on the supplied Document to match this document.
public void SetDocumentInfo(Document document)
Sub SetDocumentInfo(document As Document)
Parameters
- document: Document
A document to set.
Licensing
This class is a DynamicPDF Merger Standard Edition feature. One of the following licenses is required for non-evaluation usage:
- DynamicPDF Merger for .NET Standard Edition
- DynamicPDF Merger for .NET Professional Edition
- DynamicPDF Merger for .NET Enterprise Edition
- DynamicPDF Core Suite for .NET Professional Edition
- DynamicPDF Core Suite for .NET Enterprise Edition
ToString()
Returns a String that represents the current Object . (Inherited from Object)
public string ToString()
Function ToString() As String
Returns
A String that represents the current Object .