Extract fonts from PDF
Contents
[
Hide
]
In case you want to get all fonts from a PDF document, you can use Document.IDocumentFontUtilities.getAllFonts()
method provided in Document class.
Please check following code snippet in order to get all fonts from an existing PDF document:
public static void Extract_Fonts() throws FileNotFoundException
{
// The path to the documents directory.
String filePath = "<... enter file name ...>";
// Load PDF document
com.aspose.pdf.Document pdfDocument = new com.aspose.pdf.Document(filePath);
com.aspose.pdf.Font[] fonts = pdfDocument.getFontUtilities().getAllFonts();
for (com.aspose.pdf.Font font : fonts)
{
font.save(new FileOutputStream(font.getFontName()));
}
}