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

inputPath string

The PDF to optimize.

outputPath string

Where to write the result. It may be the input file.

password string

For 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

input FileInfo
output FileInfo
password string

For 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(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

input Stream

The PDF, read from its current position to the end; it is left open.

output Stream

A writable stream for the result; it is left open.

password string

For 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.