Inspect fonts in PDF in C++

List the names of fonts used in a PDF document with Aspose.PDF for C++.

List document font names

Inspect the document font collection and print each name.

The example lists font names; it does not save embedded font files.

  1. Open the input PDF as a Document.
  2. Call GetAllFonts() through the document font utilities.
  3. Iterate through the Font objects and read FontName.
  4. Print each font name.

#include <Aspose.PDF.Cpp/Document.h>
#include <Aspose.PDF.Cpp/Text/Font.h>

using namespace System;
using namespace Aspose::Pdf;
void ExtractFonts(System::String inputFile)
{

    // Open PDF document
    auto document = MakeObject<Document>(inputFile);
    auto fonts = document->get_FontUtilities()->GetAllFonts();
    for (auto& font : fonts)
    {
        Console::WriteLine(System::String(u"Font Name: {0}"), font->get_FontName());
    }
}