Inspect fonts in PDF in C++
Contents
[
Hide
]
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.
- Open the input PDF as a Document.
- Call GetAllFonts() through the document font utilities.
- Iterate through the Font objects and read FontName.
- 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());
}
}