When working with PDF files, you may need to know which fonts are embedded or referenced inside the document. Instead of using online tools that could expose private information, you can use the pdffonts, a command line program included with the Poppler utilities. This tutorial demonstrates how to analyze fonts in PDF file using Poppler pdffonts.
Prepare environment
Make sure the Poppler utilities are installed on the system. If you are using Ubuntu, you can follow the installation guide.
Checking fonts in PDF
Let's download a sample PDF that contains several different fonts:
curl -sSo test.pdf https://raw.githubusercontent.com/Hopding/pdf-lib/master/assets/pdfs/standard_fonts_demo.pdf
Now, run the following command:
pdffonts test.pdf
You'll get output that lists all fonts found in the document:
name type encoding emb sub uni object ID
------------------------------------ ----------------- ---------------- --- --- --- ---------
Helvetica Type 1 WinAnsi no no no 7 0
Helvetica-Bold Type 1 WinAnsi no no no 5 0
Helvetica Type 1 WinAnsi no no no 4 0
Helvetica Type 1 WinAnsi no no no 11 0
Times-Roman Type 1 WinAnsi no no no 10 0
Times-Bold Type 1 WinAnsi no no no 13 0
Times-Italic Type 1 WinAnsi no no no 14 0
Times-BoldItalic Type 1 WinAnsi no no no 15 0
Helvetica Type 1 WinAnsi no no no 18 0
Helvetica Type 1 WinAnsi no no no 17 0
Helvetica-Bold Type 1 WinAnsi no no no 20 0
Helvetica-Oblique Type 1 WinAnsi no no no 21 0
Helvetica-BoldOblique Type 1 WinAnsi no no no 22 0
Helvetica Type 1 WinAnsi no no no 25 0
Courier Type 1 WinAnsi no no no 24 0
Courier-Bold Type 1 WinAnsi no no no 27 0
Courier-Oblique Type 1 WinAnsi no no no 28 0
Courier-BoldOblique Type 1 WinAnsi no no no 29 0
Helvetica Type 1 WinAnsi no no no 32 0
ZapfDingbats Type 1 ZapfDingbats no no no 30 0
Symbol Type 1 Symbol no no no 34 0
Each row tells you the font name, type, encoding, and whether it's embedded in the PDF.
Checking fonts for specific page range
You don't need to inspect the entire PDF document. With pdffonts
command, you can narrow down the analysis to a specific set of pages by using -f
(first page) and -l
(last page). For example, to look only at pages 2 through 4:
pdffonts -f 2 -l 4 test.pdf
Leave a Comment
Cancel reply