Search code examples
pdfcommand-lineghostscriptpostscriptpdftk

PHP: How to tell if PDF has embedded fonts?


Given a PDF document, is there a way to tell if it has embedded fonts? I'm working on the problem posted here: PDF: How to Optimize Filesize & Convert to PNG (embedded fonts problem). Perhaps I can rework some of my application's logic based on whether a PDF has embedded fonts or not.


Solution

  • Use pdffonts (*nix) or pdffonts.exe (*doz). They are part of XPDF.

    1. To see which fonts are used (not necessarily embedded!) on pages 4-6 of a PDF:

      pdffonts ^
          -f 4 ^
          -l 6 ^
          input.pdf
      
    2. To get a list of all fonts used in a PDF, simply skip the -f 4 -l 6 part...

    3. Now to differentiate between embedded and non-embedded fonts, learn...

      (a) ...the general meaning of the yes and no keywords, and
      (b) ...how to interprete these keywords in the context of a list column carrying the heading emb