Extract Fonts from PDF via Python

Contents
[ ]

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.

  1. Open the source PDF as a Document.
  2. Call document.font_utilities.get_all_fonts() to get the font collection.
  3. Iterate through the returned Font objects.
  4. Read and print each font.font_name value.

    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)