PdfDocument.Open(Stream, Boolean, OpenOptions, CancellationToken) Method
Loads a PDF file from a stream.
public static PdfDocument Open( Stream stream, bool leaveOpen = false, OpenOptions? options = null, CancellationToken cancellationToken = default )
Parameters
- stream Stream
- Stream to read the PDF content from. The stream must be seekable.
- leaveOpen Boolean (Optional)
- If true, the stream is left open when the returned PdfDocument is disposed.
- options OpenOptions (Optional)
- Additional options for loading the PDF.
- cancellationToken CancellationToken (Optional)
- Token for monitoring cancellation requests.
Return Value
PdfDocumentPdfDocument for the specified stream.
Exceptions
Exception | Condition |
---|---|
ArgumentException | stream is not readable and/or seekable. |
ArgumentNullException | stream is null. |
InvalidCredentialException | The input PDF is encrypted, but an incorrect password was specified, or not specified at all. |
PdfException | The input PDF could not be parsed. |