Welcome, guest | Sign In | My Account | Store | Cart

Finds all fonts used in a PDF document by page. This new script is based on PyMuDF v1.9.2 and works for PDF files only. However, it is a lot simpler, speed has drastically improved and there is no dependency on other packages any more.

Python, 20 lines
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
#! /usr/bin python
# -*- coding: utf-8 -*-
"""
@created: 2016-04-23 13:40:00
@updated: 1016-08-25 20:00:00
@author: Jorj X. McKie

Find all fonts used in a PDF.
"""
from __future__ import print_function
import fitz                       # PyMuPDF

doc = fitz.open("file.pdf")

for i in len(doc):
    fontlist = doc.getPageFontList(i)
    if fontlist:
        print("fonts used on page", i)
    for font in fontlist:
        print("xref=%s, gen=%s, type=%s, basefont=%s, name=%s" % (font[0], font[1], font[2], font[3], font[4]))

PyMuPDF (bindings for MuPDF / fitz) support all Python version 2.7 or above (32bit or 64bit) on Windows, Linux and Mac.

Created by Jorj X. McKie on Mon, 25 Apr 2016 (MIT)
Python recipes (4591)
Jorj X. McKie's recipes (22)

Required Modules

Other Information and Tasks