0
votes

I have been trying to embed all missing fonts in a pdf just to avoid "surprises" when printing or rendering them because of the font substitution.

So i have created a document containing just "Bergamo Std" text using BergamoStd font. After that used Pdf Creator to generate a pdf without font embedding: BergamoStd.pdf

Using C#/iText i embed the font into pdf. (BergamoStd-embedded.pdf) I can correctly render the embedded pdf with or without the font being present in the system. Adobe reader, qpdfview, evince render the pdf without problems and acrobat reader tells the font is embedded as well as pdffonts.

qpdf is not reporting anything bad with this pdf.

If i use ghostscript (9.07) to generate a ps file from the embedded pdf i get a ps that can be rendered and printed ok and the font is also embedded in that ps file. pdf2ps of course gets the same resoults as ghostscript does. even xpdf in windows produces a valid ps file, with the font embedded.

but if i use pdftops from poppler-utils (v0.24) to generate the ps file i get a small ps file with no font embedded.

Even further; pdftops can not embed the font in the .ps even if the bergamoStd.ttf file is present in the system, no matter if the input pdf is the one with or without the font embedded.

Can anybody explain why pdftops cant embed this font? Am i missing something?

my test files are available here if you dont want to generate your own files following the steps i described before.

TIA.

1
How exactly did you post-facto embed the font using iTextSharp?mkl
I followed the same itext example you mentioned (using itextSharp) as the font isn't TrueType i used PdfName.FONTFILE3 instead. So i need to specify required Subtype, for that i followed this iText post. This way the pdf is 'close enough' to rightness, and many tools report nothing bad, but pdftops do, and @VadimR explained why.Nomada

1 Answers

1
votes

There's a problem with your file Bergamo Std-embeded.pdf. Embedded font is marked as "Type1C" (Type1 Compact, or CFF) in FontDescriptor > FontFile3 > Subtype entry of font dictionary. And it's reported as such by e.g. pdffonts (poppler-utils) or mutool (of MuPDF). But in reality, it's embedded unchanged in original OpenType format. You can extract it from PDF with e.g. mutool and compare with BergamoStd-Regular.otf - same files.

What C#/iText should have done (or you, if it's developer responsibility with this library) is either explicitly mark Subtype of embedded FontFile as OpenType (PDF 1.6 feature), or convert BergamoStd-Regular.otf to pfb (or further to cff, maybe - if everything is controlled manually) before embedding.

I changed "Type1C" string to "OpenType" in your Bergamo Std-embeded.pdf (using Enfocus PDF Browser, but PoDoFo or PDFEdit should do the job, too), and then pdftops created correct (i.e. font embedded) postscript from fixed pdf. I think (but didn't check) that converting otf file to cff and embedding it in-place will also fix original pdf.

It looks like all utilities you mentioned are very permissive regarding minor PDF syntax violation, but pdftops is not.