galkahana / HummusJS

Node.js module for high performance creation, modification and parsing of PDF files and streams
http://www.pdfhummus.com
Other
1.14k stars 169 forks source link

Is it possible to see if a font is NOT embedded #233

Open peter-borgstedt opened 6 years ago

peter-borgstedt commented 6 years ago

I'm creating a parser so I get the Font and Font Descriptors, but how do I determine if it is embedded or not?

chunyenHuang commented 6 years ago

Font will be saved as an object and so does it's embedded file.

In the font indirect object reference dictionary, you will find the following things

BaseFont, Encoding, FirstChar, FontDescriptor(object), LastChar, Name, Subtype, Type, Widths

If the font is embedded, it should stream from on of the following stream inside FontDescriptor

FontFile, FontFile2, FontFile3

The overall structure is

Root
  Pages
    Kids[]
      Resources
        Font
          F0
            BaseFont
            FontDescriptor
              FontFile/FontFile2/FontFile3 (Stream . iterating stream dictionary if embedded)