Method FromStream
- Namespace
- SoftZenPdf
- Assembly
- SoftZenPdf.dll
FromStream(Stream, string?)
Reads a PDF from a stream, such as a MemoryStream, an upload or a network response.
public static PdfReader FromStream(Stream stream, string? password = null)
Parameters
streamStreamA readable stream. It is read from its current position to the end; the reader keeps its own copy of the bytes, so the stream is not needed afterwards and is left open for the caller to dispose.
passwordstringFor encrypted files, the user or owner password.
Returns
- PdfReader
A reader over the data.
Examples
using var stream = new MemoryStream();
document.Save(stream);
stream.Position = 0;
var reader = PdfReader.FromStream(stream);
Exceptions
- ArgumentException
The stream cannot be read.
- InvalidDataException
The data is not a PDF, or is damaged beyond repair.
- PdfPasswordException
The file is encrypted and the password is missing or wrong.
- NotSupportedException
The file uses an unsupported security handler or encryption revision.