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
)
Namespace
PdfToSvg
Package
PdfToSvg.NET (since v0.7.0)

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

PdfDocument
PdfDocument for the specified stream.

Exceptions

ExceptionCondition
ArgumentExceptionstream is not readable and/or seekable.
ArgumentNullExceptionstream is null.
InvalidCredentialExceptionThe input PDF is encrypted, but an incorrect password was specified, or not specified at all.
PdfExceptionThe input PDF could not be parsed.
OperationCanceledExceptionThe operation was cancelled because the cancellation token was triggered.

See Also

PdfDocument Class
Open Overload
PdfToSvg Namespace