python-poppler icon indicating copy to clipboard operation
python-poppler copied to clipboard

Is it possible to know using this tool if a font is embedded and has to_unicode map?

Open kfcaio opened this issue 4 years ago • 1 comments

The workflow of one of my scripts relies on calling subprocess.run for each pdf page to get its respective pdffonts output. Those calls are expensive, so I'm looking forward to better ways to identify likely problematic fonts from font name, enconding, "embeddedness" and unicode conversion.

Example of pdffonts output:

name                                 type              encoding         emb sub uni object ID
------------------------------------ ----------------- ---------------- --- --- --- ---------
DIIEDG+Arial                         CID TrueType      Identity-H       yes yes no   51834  0
DIIEDH+Arial                         CID TrueType      Identity-H       yes yes no   51831  0
DIIDPF+ArialMT                       CID TrueType      Identity-H       yes yes yes  51824  0
DIIEBG+TimesNewRomanPSMT             CID TrueType      Identity-H       yes yes yes  51821  0
[none]                               Type 3            Custom           yes no  no   51861  0
Arial                                TrueType          WinAnsi          yes no  no   67975  0

Is it possible to extract those informations just with poppler backend used here? I just took a look at the source code and I've not found something like that.

Thanks in advance,

kfcaio avatar Jul 31 '21 06:07 kfcaio

From the document, you can get the list of fonts.

For each font, you can get its name, its type, its embeddedness, its file name, and if a subset is embedded in the document. See https://poppler.freedesktop.org/api/cpp/classpoppler_1_1font__info.html

However,encoding and unicode conversion are not exposed in the cpp backend. You may request upstream to add them.

cbrunet avatar Aug 12 '21 02:08 cbrunet