Method Open
Open(byte[], PdfReadOptions?)
Opens a PDF from a byte array. The array is not copied and must not be modified while the document is open.
public static PdfDocument Open(byte[] bytes, PdfReadOptions? options = null)
Parameters
bytesbyte[]The file contents.
optionsPdfReadOptionsRead options, or null for the defaults.
Returns
- PdfDocument
The opened document.
Exceptions
- ArgumentNullException
bytesis null.- InvalidDocumentException
The bytes are not a PDF.
- ResourceLimitExceededException
A configured limit was exceeded.
Open(Stream, PdfReadOptions?)
Opens a PDF from a stream, reading it fully into memory.
public static PdfDocument Open(Stream stream, PdfReadOptions? options = null)
Parameters
streamStreamThe stream, read from its current position to the end.
optionsPdfReadOptionsRead options, or null for the defaults.
Returns
- PdfDocument
The opened document.
Remarks
A PDF is a random-access format: opening one means reading its trailer, then jumping to objects scattered through the file. There is no streaming read that is not simply a buffered one, so the bytes are materialized once and the caller can see what that costs.
Exceptions
- ArgumentNullException
streamis null.- InvalidDocumentException
The stream does not hold a PDF.
Open(string, PdfReadOptions?)
Opens a PDF from a file path.
public static PdfDocument Open(string path, PdfReadOptions? options = null)
Parameters
pathstringThe file path.
optionsPdfReadOptionsRead options, or null for the defaults.
Returns
- PdfDocument
The opened document.
Exceptions
- ArgumentNullException
pathis null.- InvalidDocumentException
The file does not hold a PDF.