Table of Contents

Method Open

Namespace
DocWright.Formats.Pdf
Assembly
DocWright.Formats.Pdf.dll

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

bytes byte[]

The file contents.

options PdfReadOptions

Read options, or null for the defaults.

Returns

PdfDocument

The opened document.

Exceptions

ArgumentNullException

bytes is 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

stream Stream

The stream, read from its current position to the end.

options PdfReadOptions

Read 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

stream is 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

path string

The file path.

options PdfReadOptions

Read options, or null for the defaults.

Returns

PdfDocument

The opened document.

Exceptions

ArgumentNullException

path is null.

InvalidDocumentException

The file does not hold a PDF.