Method Optimize
- Namespace
- SoftZenPdf.Optimizer
- Assembly
- SoftZenPdf.Optimizer.dll
Optimize(string, string, string?)
Optimizes a PDF file.
public OptimizationResult Optimize(string inputPath, string outputPath, string? password = null)
Parameters
inputPathstringThe PDF to optimize.
outputPathstringWhere to write the result. It may be the input file.
passwordstringFor encrypted files, the user or owner password.
Returns
- OptimizationResult
What was changed and how much was saved.
Exceptions
- UnauthorizedAccessException
The file's permissions do not allow changing its content; supply the owner password.
- PdfPasswordException
The file is encrypted and the password is missing or wrong.
Optimize(FileInfo, FileInfo, string?)
Optimizes a PDF file.
public OptimizationResult Optimize(FileInfo input, FileInfo output, string? password = null)
Parameters
Returns
- OptimizationResult
What was changed and how much was saved.
Exceptions
- UnauthorizedAccessException
The file's permissions do not allow changing its content; supply the owner password.
- PdfPasswordException
The file is encrypted and the password is missing or wrong.
Optimize(Stream, Stream, string?)
Optimizes a PDF read from a stream and writes the result to another stream.
public OptimizationResult Optimize(Stream input, Stream output, string? password = null)
Parameters
inputStreamThe PDF, read from its current position to the end; it is left open.
outputStreamA writable stream for the result; it is left open.
passwordstringFor encrypted files, the user or owner password.
Returns
- OptimizationResult
What was changed and how much was saved.
Exceptions
- UnauthorizedAccessException
The file's permissions do not allow changing its content; supply the owner password.
- PdfPasswordException
The file is encrypted and the password is missing or wrong.