You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@pdfbox.apache.org by Foley Ma <fo...@gmail.com> on 2013/02/19 18:28:14 UTC
Converting to png when fonts are missing using split
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)
Re: Converting to png when fonts are missing using split
Posted by Foley Ma <fo...@gmail.com>.
As a follow up to my previous e-mail, I installed the font and it seems
like the png still does not contain the text. Has anyone encountered this
before or have a suggestion? Thanks.
Foley
On Tue, Feb 19, 2013 at 12:28 PM, Foley Ma <fo...@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)
>
>
>
>
Re: Converting to png when fonts are missing using split
Posted by Foley Ma <fo...@gmail.com>.
Hello again,
I tried something else to narrow down the issue. I used Microsoft Word,
created a document using the same font and that was able to convert fine. I
guess there's an issue with the pdf. Does anyone have a suggestion on how I
can go about examining the issue with the pdf? Maybe there's an issue with
some metadata embedded in it?
Thanks,
Foley
On Tue, Feb 19, 2013 at 12:28 PM, Foley Ma <fo...@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)
>
>
>
>