Subset fonts

On this page

Not optimized files may contain embedded fonts. GroupDocs.Viewer can remove unused instructions in embedded fonts to reduce the file size.

To subset fonts in a PDF file, set the subset_fonts property to True.

The following code snippet shows how to subset fonts in a PDF file:

with gv.Viewer("sample.docx") as viewer:

    viewOptions = gvo.PdfViewOptions()
    viewOptions.pdf_optimization_options = gvo.PdfOptimizationOptions()
    viewOptions.pdf_optimization_options.subset_fonts = True

    viewer.view(viewOptions)

The following image demonstrates the result. There is no difference in appearance:

No difference in appearance

But there is the significant difference in size:

Significant difference in size

On this page