PdfOptimizer Class
Makes documents smaller or removes what they do not need, in two steps: PdfOptimizer.CreatePlan lists the changes without making them, and PdfOptimizer.Apply makes the changes of the plan that are enabled.
public static class PdfOptimizerRemarks
The changes are made to the document model: save the document to write them. A full save writes only the objects reachable from the trailer, so the removed objects are not written.
Methods
| Name | Description |
|---|---|
| Apply(PdfOptimizationPlan) | Makes the enabled changes of a plan. |
| CreatePlan(PdfDocument, PdfOptimizationOptions) | Lists the changes the options ask for, without changing the document. |
Apply(PdfOptimizationPlan)
PdfOptimizer.csMakes the enabled changes of a plan.
public static IReadOnlyList<PdfOptimizationAction> Apply(PdfOptimizationPlan plan)Parameters
planPdfOptimizationPlan- The plan, from
PdfOptimizer.CreatePlan.
Returns
IReadOnlyList<PdfOptimizationAction> The actions that changed the document; an action whose target was already removed (by another action, or since the plan was created) does not.
Exceptions
InvalidOperationException- The plan invalidates signatures, and
PdfOptimizationOptions.AllowSignatureInvalidationisfalse. PdfException- The document cannot be read.
CreatePlan(PdfDocument, PdfOptimizationOptions)
PdfOptimizer.csLists the changes the options ask for, without changing the document.
public static PdfOptimizationPlan CreatePlan(PdfDocument document, PdfOptimizationOptions options)Parameters
documentPdfDocument- The document.
optionsPdfOptimizationOptions- The changes to plan.
Returns
PdfOptimizationPlan The plan.
Exceptions
PdfException- The document cannot be read.