Q: I’m attempting to optimise a PDF which has duplicate font definitions in it but when I run it through your PDF optimiser the duplicate font definitions remain. Could you have a look?
The code I’m using to call the optimiser is:
using (pdftron.PDF.PDFDoc doc = new PDFDoc(“Input.pdf”)) {
pdftron.PDF.Optimizer.OptimizerSettings OS = new Optimizer.OptimizerSettings();
pdftron.PDF.Optimizer.ImageSettings IS = new Optimizer.ImageSettings();
pdftron.PDF.Optimizer.TextSettings TS = new Optimizer.TextSettings();
pdftron.PDF.Optimizer.MonoImageSettings MS = new Optimizer.MonoImageSettings();
TS.EmbedFonts(true);
IS.SetCompressionMode(Optimizer.ImageSettings.CompressionMode.e_retain);
IS.SetDownsampleMode(Optimizer.ImageSettings.DownsampleMode.e_off);
IS.SetQuality(100);
MS.SetDownsampleMode(Optimizer.MonoImageSettings.DownsampleMode.e_off);
OS.SetColorImageSettings(IS);
OS.SetGrayscaleImageSettings(IS);
OS.SetMonoImageSettings(MS);
OS.SetTextSettings(TS);
pdftron.PDF.Optimizer.Optimize(doc, OS);
doc.Save(@“C:\Output.pdf”, pdftron.SDF.SDFDoc.SaveOptions.e_remove_unused);
}
I’m using v6.1.1 of the pdftron library under .Net 4.
A:
Optimizer may not remove duplicate dictionaries. The main reason is that this can cause compatibility issues with third party apps… also the space savings is usually negligible and not worth the trouble. However, duplicate streams in fonts (and elsewhere) are optimized and replaced with a single instance . (so the FontFile3 entries are shared between those fonts)