Class PdfDocument
Provides access to document level information for this PDF document as well as access to the Pages contained in the document.
public class PdfDocument : IDisposable
- Inheritance
-
PdfDocument
- Implements
- Inherited Members
Properties
Advanced
Access to rare or advanced features of the PDF specification.
public AdvancedPdfDocumentAccess Advanced { get; }
Property Value
Information
The metadata associated with this document.
public DocumentInformation Information { get; }
Property Value
IsEncrypted
Whether the document content is encrypted.
public bool IsEncrypted { get; }
Property Value
NumberOfPages
Get the number of pages in this document.
public int NumberOfPages { get; }
Property Value
Structure
Access to the underlying raw structure of the document.
public Structure Structure { get; }
Property Value
Version
The version number of the PDF specification which this file conforms to, for example 1.4.
public decimal Version { get; }
Property Value
Methods
Dispose()
Dispose the PdfDocument and close any unmanaged resources.
public void Dispose()
GetPage(int)
Get the page with the specified page number (1 indexed).
public Page GetPage(int pageNumber)
Parameters
pageNumber
intThe number of the page to return, this starts from 1.
Returns
- Page
The page.
GetPages()
Gets all pages in this document in order.
public IEnumerable<Page> GetPages()
Returns
Open(byte[], ParsingOptions)
Creates a PdfDocument for reading from the provided file bytes.
public static PdfDocument Open(byte[] fileBytes, ParsingOptions options = null)
Parameters
fileBytes
byte[]The bytes of the PDF file.
options
ParsingOptionsOptional parameters controlling parsing.
Returns
- PdfDocument
A PdfDocument providing access to the file contents.
Open(Stream, ParsingOptions)
Creates a PdfDocument for reading from the provided stream. The caller must manage disposing the stream. The created PdfDocument will not dispose the stream.
public static PdfDocument Open(Stream stream, ParsingOptions options = null)
Parameters
stream
StreamA stream of the file contents, this must support reading and seeking. The PdfDocument will not dispose of the provided stream.
options
ParsingOptionsOptional parameters controlling parsing.
Returns
- PdfDocument
A PdfDocument providing access to the file contents.
Open(string, ParsingOptions)
Opens a file and creates a PdfDocument for reading from the provided file path.
public static PdfDocument Open(string filePath, ParsingOptions options = null)
Parameters
filePath
stringThe full path to the file location of the PDF file.
options
ParsingOptionsOptional parameters controlling parsing.
Returns
- PdfDocument
A PdfDocument providing access to the file contents.
TryGetBookmarks(out Bookmarks)
Gets the bookmarks if this document contains some.
public bool TryGetBookmarks(out Bookmarks bookmarks)
Parameters
bookmarks
Bookmarks
Returns
Remarks
This will throw a ObjectDisposedException if called on a disposed PdfDocument.
TryGetForm(out AcroForm)
Gets the form if this document contains one.
public bool TryGetForm(out AcroForm form)
Parameters
form
AcroForm
Returns
Remarks
This will throw a ObjectDisposedException if called on a disposed PdfDocument.
TryGetXmpMetadata(out XmpMetadata)
Get the document level metadata if present. The metadata is XML in the (Extensible Metadata Platform) XMP format.
public bool TryGetXmpMetadata(out XmpMetadata metadata)
Parameters
metadata
XmpMetadataThe metadata stream if it exists.
Returns
Remarks
This will throw a ObjectDisposedException if called on a disposed PdfDocument.