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 SubsetFonts property to true.

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

using GroupDocs.Viewer;
using GroupDocs.Viewer.Options;
// ...

using (var viewer = new Viewer("sample.docx"))
{
    PdfViewOptions viewOptions = new PdfViewOptions();
    viewOptions.PdfOptimizationOptions = new PdfOptimizationOptions
    {
        SubsetFonts = true
    };
     
    viewer.View(viewOptions);
}
Imports GroupDocs.Viewer
Imports GroupDocs.Viewer.Options
' ...

Module Program
    Sub Main(args As String())
        Using viewer = New Viewer("sample.docx")
            Dim viewOptions As PdfViewOptions = New PdfViewOptions()
            viewOptions.PdfOptimizationOptions = New PdfOptimizationOptions With {
                .SubsetFonts = True
                }
    
            viewer.View(viewOptions)
        End Using
    End Sub
End Module

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