Embeding and subsetting missing fonts in PDF

Q:

I am trying to use ‘pdftron.PDF.Optimizer’ to embed and subset missing fonts in my PDFs.
This is to prevent text issues on mobile devices (since most viewers do not properly render PDFs with missing fonts).

I tried to solve this with the following code:

Optimizer.TextSettings ts = new Optimizer.TextSettings();

ts.embedFonts(true);

ts.subsetFonts(true);

Optimizer.OptimizerSettings optSettings = new

Optimizer.OptimizerSettings();

optSettings.setTextSettings(ts);

Optimizer.optimize(doc, optSettings);

but it does not seem not work. I still see wrong fonts on my tablet.

A:

We tested your file and it seems that PDFNet Optimizer is properly embedding fonts (i.e. the fonts are not being substituted) .

You can verify this under Doc ‘Properties’ > ‘Fonts’ tab… all fonts are marked as embedded and subsetted.

The problem is that the fonts selected for embedding are not correct in the first place.

To fix this you need to make sure that all original / referenced fonts are present on the target machine (i.e. BauerBodoni and its variants should be installed and present in System / Fonts folder).

In case you would like to override default font substitution you could use PDFNet.AddFontSubst(…);

For example:

PDFNet.Initialize(…);

pdftron.PDFNet.AddFontSubst("BauerBodoni ", @“C:\Windows\Fonts\Times New Roman\my.ttf”);

pdftron.PDFNet.AddFontSubst(“TimesNewRomanPSMT”, @“C:\Windows\Fonts\Times New Roman\times.ttf”);

For more samples, please see commented-out code at the beginning of PDFDraw sample project.