PDFFile¶
Namespace: O2S.Components.PDF4NET.Core
Defines a PDF file.
Constructors¶
PDFFile(Stream)¶
Initializes a new PDFFile object from a stream.
Parameters
stream Stream
Stream with the PDF file.
Remarks
The PDFFile class is used to extract various objects from the PDF file. The 'stream' must be kept open as long as the PDFFile object is used because the content is read from the stream when the corresponding methods are called.
PDFFile(Stream, String)¶
Initializes a new PDFFile object from a stream.
Parameters
stream Stream
Stream with the PDF file.
password String
Password for decrypting the PDF file.
Remarks
The PDFFile class is used to extract various objects from the PDF file. The 'stream' must be kept open as long as the PDFFile object is used because the content is read from the stream when the corresponding methods are called.
Properties¶
PageCount¶
Gets the number of pages.
Property Value
Int32
The number of pages in the PDF file.
SecurityHandler¶
Gets the file security handler.
Property Value
PDFSecurityHandler
The security handler that was used to encrypt the PDF file.
Methods¶
ExtractDocumentInformation()¶
Extracts the document information from the PDF files.
Returns
PDFDocumentInformation
The document information, if it exists in the PDF file.
ExtractFileAttachments()¶
Extracts the file attachments from the PDF file.
Returns
PDFDocumentFileAttachmentCollection
The collection of file attachments in the PDF file.
ExtractJavaScriptFragments()¶
Extracts the JavaScript code from the PDF file.
Returns
PDFJavaScriptBlockCollection
The collection of JavaScript fragments in the PDF file.
ExtractNamedDestinations()¶
Extracts the named destinations from the PDF file.
Returns
PDFNamedDestinationCollection
The collection of named destinations in the PDF file.
ExtractNamedDestinations(Boolean)¶
Extracts the named destinations from the PDF file.
Parameters
enableFastLookup Boolean
True if fast lookup should be enabled for the named destinations collection.
Returns
PDFNamedDestinationCollection
The collection of named destinations in the PDF file.
ExtractOutlines()¶
Extracts the outlines from the PDF file.
Returns
PDFOutlineItemCollection
The collection of outlines in the PDF file
ExtractPage(Int32)¶
Extracts a page from the PDF file.
Parameters
pageNumber Int32
The page to extract.
Returns
PDFPage
The PDF page.
ExtractPageContent(Int32, Boolean, Boolean)¶
Extracts the content of a PDF page.
public PDFPageContent ExtractPageContent(int pageNumber, bool includeAnnotations, bool includeFormFields)
Parameters
pageNumber Int32
The page to extract the content from.
includeAnnotations Boolean
True if annotations should be flattened and included in page content
includeFormFields Boolean
True if form fields should be flattened and included in page content
Returns
PDFPageContent
The page content in vector format.
ExtractPageContent(Int32, PDFDisplayRectangle, Boolean, Boolean)¶
Extracts the content of a PDF page.
public PDFPageContent ExtractPageContent(int pageNumber, PDFDisplayRectangle clipRectangle, bool includeAnnotations, bool includeFormFields)
Parameters
pageNumber Int32
The page to extract the content from.
clipRectangle PDFDisplayRectangle
A rectangle to clip the page content to specified area.
includeAnnotations Boolean
True if annotations should be flattened and included in page content
includeFormFields Boolean
True if form fields should be flattened and included in page content
Returns
PDFPageContent
The page content in vector format.
ExtractPageContent(Int32, Int32, Boolean, Boolean)¶
Extracts the content of a PDF page set.
public PDFPageContent[] ExtractPageContent(int fromPage, int toPage, bool includeAnnotations, bool includeFormFields)
Parameters
fromPage Int32
Start page to extract the content from.
toPage Int32
End page to extract the content from.
includeAnnotations Boolean
True if annotations should be flattened and included in page content
includeFormFields Boolean
True if form fields should be flattened and included in page content
Returns
PDFPageContent[]
Array of page contents in vector format.
ExtractPageInfo(Int32)¶
Extracts the page information from the PDF file.
Parameters
pageNumber Int32
The page number for which the information is extracted.
Returns
PDFPageInfo
Information about the page.
ExtractPageOptionalContentGroup(Int32, String)¶
Extracts the content of an optional content group.
Parameters
pageNumber Int32
The page to extract the optional content from.
ocgName String
The name of the optional content group to be extracted.
Returns
PDFPageOptionalContent
The page optional content group in vector format.
ExtractPageOptionalContentGroupNames(Int32)¶
Extracts the names of the optional content groups defined on the page.
Parameters
pageNumber Int32
The page to extract the optional content group names from.
Returns
String[]
An array of strings representing the optional content groups defined on the page or null if the page does not contain any optional content groups.
ExtractPages(Int32, Int32)¶
Extracts a page from the PDF file.
Parameters
fromPage Int32
Start page to extract.
toPage Int32
End page to extract.
Returns
PDFPage[]
An array of PDF pages.
ExtractXmpMetadata()¶
Extracts the XMP metadata from the PDF file.
Returns
String
The XMP metadata, if it exists in the PDF file.
GetCosObjectByNumber(UInt32, Boolean)¶
Gets the specified COS object.
Parameters
objectNumber UInt32
The object number of the specified COS object.
loadStreamContent Boolean
Returns
PDFCosObject
The COS object if exists, null otherwise.
GetCosObjectCount()¶
Gets the total number of COS objects in the PDF file.
Returns
Int32
The total number of COS objects in the PDF file.
GetPDFFileEncryptionAlgorithm(Stream, Int32&)¶
Gets the encryption algorithm used by the PDF file in the input stream.
Parameters
stream Stream
Stream that contains the PDF file.
keySize Int32&
Returns the size in bits of the encryption key.
Returns
PDFEncryptionAlgorithm
The encryption algorithm.
IsPDFFileEncrypted(Stream)¶
Verifies if the PDF file is encrypted.
Parameters
stream Stream
Stream that contains the PDF file.
Returns
Boolean
True if the PDF file is encrypted, false otherwise.
IsPDFFileOwnerPassword(Stream, String)¶
Verifies if the password matches the owner password set on the PDF file.
Parameters
stream Stream
Stream that contains the PDF file.
password String
Password to verify.
Returns
Boolean
True if the password is the owner password, false if the password is not the owner password or the file is not encrypted.
IsPDFFileUserPassword(Stream, String)¶
Verifies if the password matches the user password set on the PDF file.
Parameters
stream Stream
Stream that contains the PDF file.
password String
Password to verify.
Returns
Boolean
True if the password is the user password, false if the password is not the user password or the file is not encrypted.