The property removes unused (orphaned) streams from a PDF file that are referenced in the page resource dictionary but never used in the page contents. Disabled by default (False); setting it to True reduces the output PDF size.
The property subsets fonts in the output PDF file.
Example
fromgroupdocs.viewerimportViewerfromgroupdocs.viewer.optionsimportPdfViewOptions,PdfOptimizationOptionsdefoptimize_pdf():withViewer("sample.docx")asviewer:view_options=PdfViewOptions("output/optimized.pdf")view_options.pdf_optimization_options=PdfOptimizationOptions()# Enable linearization for faster web previewview_options.pdf_optimization_options.lineriaze=True# Remove annotations and form fields to reduce sizeview_options.pdf_optimization_options.remove_annotations=Trueview_options.pdf_optimization_options.remove_form_fields=Trueviewer.view(view_options)