Extract Fonts from PDF via Python
Contents
[
Hide
]
Use Document to open the PDF and call font_utilities.get_all_fonts() to retrieve all available Font objects referenced by the document. This is useful when auditing embedded fonts, checking font availability before conversion, or analyzing document resources.
- Open the source PDF as a
Document. - Call
document.font_utilities.get_all_fonts()to get the font collection. - Iterate through the returned
Fontobjects. - Read and print each
font.font_namevalue.
import aspose.pdf as apdf
from os import path
path_infile = path.join(self.dataDir, infile)
# Open PDF document
document = apdf.Document(path_infile)
fonts = document.font_utilities.get_all_fonts()
for font in fonts:
print(font.font_name)