Hi...I'm having font-loading issues, so I'm trying to find out what fonts are included in PDFs my Java program is sending to the printer. My understanding is that this would be Document.getPageTree().getResources.getFonts(), but the getResources() call is returning null.
Document pdf = new Document();
Exception exception = null;
// load the file specified by the command line
System.out.println("Number of pages: " + pdf.getNumberOfPages());
PageTree pagetree = pdf.getPageTree();
System.out.println("PageTree: number of pages: " + pagetree.getNumberOfPages());
Page page = pagetree.getPage(1);
if (page == null)
System.out.println("Page 1 came back null.");
Resources resources = pagetree.getResources();
if (resources == null)
System.out.println("Resources came back null.");
HashMap fonts = resources.getFonts();
Number of pages: 3
PageTree: number of pages: 3
Resources came back null.
I also tried pagetree.getPage(1).getResources, but that also came back null.
Your close, this particular case the pageTree doesn't haven any resources. Generally the Page object will contain all the resources for the page. In theory common resources could be attached to the pageTree but encoders never seem to use this optimization.
Okay, thanks, that did help with seeing the fonts in that particular file. (It comes up as Calibri.) Trying it with three other files (which unfortunately I'm not allowed to show you) which were produced with iText comes up with two null font lists and one page 1 not found. The last one was a PDF containing nothing but an image, but the other two have fonts in them that I can see in Adobe Reader using right-click->DocumentProperties->Fonts.