Hello again, I think I may have found the issue. In Splitter.processNextPage it sets the resources using page.getResources(). I think it should be page.findResources. I guess the sample pdf I had did not have the resources on that page and it's required the go up the hierarchy.
Is there a reason why findResources was not used in the first place, that would invalidate this fix? In the comment of getResources it says you may want to used findResources. Thanks, Foley On Tue, Feb 19, 2013 at 12:28 PM, Foley Ma <fole...@gmail.com> wrote: > Hello, > I seem to have run into an issue with converting a pdf to png when fonts > are missing. > > I've included in the attachment a small maven project with an example pdf. > There's two test cases. > > One that converts the document by pulling a list of PDPage. > > One that splits the document, and then extracts the first PDPage in the > new split document and convert it to a png. > > In both cases I do not have the fonts on my computer (TimesNewRomanPSMT). > > I'm able to get a png with text when I do not split the document, but when > I split the document, I get a stack trace with Warnings (see below), and > the png is blank. I would have assumed that in both cases it would resort > to using the default font and text would show up. Why is this not the case > when I split the document? Am I doing something incorrectly or is this a > bug? > > Thank you, > > > Feb 19, 2013 12:15:02 PM org.apache.pdfbox.util.PDFStreamEngine > processOperator > WARNING: java.lang.NullPointerException > java.lang.NullPointerException > at > org.apache.pdfbox.util.PDFStreamEngine.processEncodedText(PDFStreamEn > gine.java:366) > at > org.apache.pdfbox.util.operator.ShowText.process(ShowText.java:45) > at > org.apache.pdfbox.util.PDFStreamEngine.processOperator(PDFStreamEngin > e.java:556) > at > org.apache.pdfbox.util.PDFStreamEngine.processSubStream(PDFStreamEngi > ne.java:270) > at > org.apache.pdfbox.util.PDFStreamEngine.processSubStream(PDFStreamEngi > ne.java:246) > at > org.apache.pdfbox.util.PDFStreamEngine.processStream(PDFStreamEngine. > java:217) > at > org.apache.pdfbox.pdfviewer.PageDrawer.drawPage(PageDrawer.java:119) > at org.apache.pdfbox.pdmodel.PDPage.convertToImage(PDPage.java:730) > at org.apache.pdfbox.pdmodel.PDPage.convertToImage(PDPage.java:688) > at > com.foleyfunctional.TestMissingFonts.convertUsingSplit(TestMissingFon > ts.java:69) > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl. > java:57) > at > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces > sorImpl.java:43) > at java.lang.reflect.Method.invoke(Method.java:601) > at > org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(Framework > Method.java:44) > at > org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCal > lable.java:15) > at > org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMe > thod.java:41) > at > org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMet > hod.java:20) > at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263) > at > org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRun > ner.java:69) > at > org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRun > ner.java:48) > at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231) > at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60) > at > org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229) > at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50) > at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222) > at org.junit.runners.ParentRunner.run(ParentRunner.java:292) > at > org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet. > java:35) > at > org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4 > Provider.java:115) > at > org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider > .java:97) > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl. > java:57) > at > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces > sorImpl.java:43) > at java.lang.reflect.Method.invoke(Method.java:601) > at > org.apache.maven.surefire.booter.ProviderFactory$ClassLoaderProxy.inv > oke(ProviderFactory.java:103) > at $Proxy0.invoke(Unknown Source) > at > org.apache.maven.surefire.booter.SurefireStarter.invokeProvider(Suref > ireStarter.java:150) > at > org.apache.maven.surefire.booter.SurefireStarter.runSuitesInProcess(S > urefireStarter.java:91) > at > org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java: > 69) > > > >