We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

FontCollection fontCollection is null when getting it like this: pageObject.getResources().getFonts();

Using FontCollection fontCollection = pageObject.getResources().getFonts(); I’m getting fontCollection equals to null. Seems like bug, because using TextFragmentAbsorber and going through the all page checking textFragment font we will find out that there are 5 fonts in the pdf (Symbol, TimesNewRomanPSMT, CMSKMO+TimesNewRomanPSMT, TimesNewRomanPS-BoldMT, TimesNewRomanPS-BoldItalicMT ):
TextFragmentAbsorber absorber = new TextFragmentAbsorber(); pageObject.accept(absorber); List<Font> fonts = new ArrayList<>(); for (TextFragment textFragment : absorber.getTextFragments()) { Font font = textFragment.getTextState().getFont(); if (fonts.stream().noneMatch(existingFont -> MATCH_FONT.apply(existingFont, font))) { fonts.add(font); } }

Also fetching fonts from the whole document, not page, works okay:
Font[] allFonts = document.getFontUtilities().getAllFonts();

Document for test: orion2-synopsis-pg1-approved.pdf

orion2-synopsis-pg1-approved.pdf (40.8 KB)

@valerijaslu

A ticket with ID PDFJAVA-40944 has been created in our issue tracking system to further investigate the issue on our end. This thread has been linked with the issue so that you may be notified once the issue will be fixed.

@valerijaslu

We have investigated the ticket. Not all fonts that are used in the PDF file must be in page resources. Page Font Resources has an optional type.

For getting all fons from the PDF file use FontUtilities:

document.getFontUtilities().getAllFonts();

documentation.jpg (219.0 KB)