You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by DImuthu Upeksha <di...@gmail.com> on 2014/06/03 19:09:51 UTC

Problem with PDFRenderer

Hi all,

I tried to render a buffered image from this [1] PDF file using following
code sample.

PDFRenderer renderer = new PDFRenderer(document);

 BufferedImage image = renderer.renderImage(currentPageNo, zoomFactor);
Then it gave following error. However this code works for other PDFs. What
could be the reason for this?

[1] https://www.dropbox.com/s/ywscxm2n8pubat5/pdf3.pdf

SEVERE: error while creating a xobject

org.apache.pdfbox.filter.MissingImageReaderException: Cannot read JBIG2
image: jbig2-imageio is not installed

at org.apache.pdfbox.filter.JBIG2Filter.decode(JBIG2Filter.java:70)

at org.apache.pdfbox.filter.Filter.decode(Filter.java:58)

at org.apache.pdfbox.cos.COSStream.doDecode(COSStream.java:359)

at org.apache.pdfbox.cos.COSStream.doDecode(COSStream.java:272)

at org.apache.pdfbox.cos.COSStream.getDecodeResult(COSStream.java:230)

at org.apache.pdfbox.pdmodel.graphics.image.PDImageXObject.<init>(
PDImageXObject.java:94)

at org.apache.pdfbox.pdmodel.graphics.PDXObject.createXObject(
PDXObject.java:65)

at org.apache.pdfbox.pdmodel.PDResources.getXObjects(PDResources.java:247)

at org.apache.pdfbox.util.operator.pagedrawer.Invoke.process(Invoke.java:57)

at org.apache.pdfbox.util.PDFStreamEngine.processOperator(
PDFStreamEngine.java:529)

at org.apache.pdfbox.util.PDFStreamEngine.processSubStream(
PDFStreamEngine.java:254)

at org.apache.pdfbox.util.PDFStreamEngine.processSubStream(
PDFStreamEngine.java:221)

at org.apache.pdfbox.util.PDFStreamEngine.processStream(
PDFStreamEngine.java:203)

at org.apache.pdfbox.rendering.PageDrawer.drawPage(PageDrawer.java:162)

at org.apache.pdfbox.rendering.PDFRenderer.renderPage(PDFRenderer.java:199)

at org.apache.pdfbox.rendering.PDFRenderer.renderImage(PDFRenderer.java:147)

at org.apache.pdfbox.rendering.PDFRenderer.renderImage(PDFRenderer.java:70)

at org.apache.pdfbox.utils.PDFOCRTextStripper.processStream(
PDFOCRTextStripper.java:51)

at org.apache.pdfbox.util.PDFTextStripper.processPage(
PDFTextStripper.java:462)

at org.apache.pdfbox.util.PDFTextStripper.processPages(
PDFTextStripper.java:387)

at org.apache.pdfbox.util.PDFTextStripper.writeText(PDFTextStripper.java:346
)

at org.apache.pdfbox.util.PDFTextStripper.getText(PDFTextStripper.java:259)

at org.apache.pdfbox.utils.PDFOCTRTextStripper_Test.test(
PDFOCTRTextStripper_Test.java:19)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(
NativeMethodAccessorImpl.java:57)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(
DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:606)

at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(
FrameworkMethod.java:44)

at org.junit.internal.runners.model.ReflectiveCallable.run(
ReflectiveCallable.java:15)

at org.junit.runners.model.FrameworkMethod.invokeExplosively(
FrameworkMethod.java:41)

at org.junit.internal.runners.statements.InvokeMethod.evaluate(
InvokeMethod.java:20)

at org.junit.internal.runners.statements.RunBefores.evaluate(
RunBefores.java:28)

at org.junit.internal.runners.statements.RunAfters.evaluate(
RunAfters.java:31)

at org.junit.runners.BlockJUnit4ClassRunner.runChild(
BlockJUnit4ClassRunner.java:70)

at org.junit.runners.BlockJUnit4ClassRunner.runChild(
BlockJUnit4ClassRunner.java:44)

at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:180)

at org.junit.runners.ParentRunner.access$000(ParentRunner.java:41)

at org.junit.runners.ParentRunner$1.evaluate(ParentRunner.java:173)

at org.junit.internal.runners.statements.RunBefores.evaluate(
RunBefores.java:28)

at org.junit.internal.runners.statements.RunAfters.evaluate(
RunAfters.java:31)

at org.junit.runners.ParentRunner.run(ParentRunner.java:220)

at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(
JUnit4TestSet.java:35)

at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(
JUnit4Provider.java:146)

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(
DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:606)

at org.apache.maven.surefire.booter.ProviderFactory$ClassLoaderProxy.invoke(
ProviderFactory.java:103)

at com.sun.proxy.$Proxy0.invoke(Unknown Source)

at org.apache.maven.surefire.booter.SurefireStarter.invokeProvider(
SurefireStarter.java:145)

at org.apache.maven.surefire.booter.SurefireStarter.runSuitesInProcess(
SurefireStarter.java:87)

at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:69)

-- 
Regards

W.Dimuthu Upeksha
Undergraduate
Department of Computer Science And Engineering

University of Moratuwa, Sri Lanka

Re: Problem with PDFRenderer

Posted by DImuthu Upeksha <di...@gmail.com>.
Nope. I just ignored it. :) I'll look into it in future after my work is
done with OCR-plugin.


On Wed, Jun 11, 2014 at 6:57 AM, John Hewson <jo...@jahewson.com> wrote:

> Does the PDF render ok? If so, then ignore the error messages. PDFs often
> contain some corrupted data.
> If not, try running the same code outside of a unit test - sometimes the
> test runner can cause problems.
>
> If you’re still having problems, then just ignore this PDF, fixing JBIG2
> bugs is not your problem right now :)
>
> -- John
>
> On 4 Jun 2014, at 08:12, DImuthu Upeksha <di...@gmail.com>
> wrote:
>
> > John,
> > I'm not sure about thread safe manner you have mentioned. How can I make
> it
> > thread safe? I'm running only this unit test so I think it is not a
> problem
> > with parallel test running.
> >
> >
> > On Wed, Jun 4, 2014 at 9:20 AM, John Hewson <jo...@jahewson.com> wrote:
> >
> >> It’s probably an issue with your unit test, are you running it in
> parallel
> >> on in some non-thread-safe manner?
> >>
> >> -- John
> >>
> >> On 3 Jun 2014, at 10:46, DImuthu Upeksha <di...@gmail.com>
> >> wrote:
> >>
> >>> Hi Tilman,
> >>>
> >>> Thank you for your quick response. I added jar to classpath but it gave
> >>> same error, Then I updated my pom file with this
> >>> https://code.google.com/p/jbig2-imageio/wiki/UsingMaven. Now exception
> >>> didn't appear but it gives following error message
> >>>
> >>> Jun 03, 2014 11:12:33 PM com.levigo.jbig2.util.log.JDKLogger info
> >>>
> >>> INFO: JBIG2ReadParam not specified. Default will be used.
> >>>
> >>> Jun 03, 2014 11:12:33 PM com.levigo.jbig2.util.log.JDKLogger info
> >>>
> >>> INFO: Globals not set.
> >>>
> >>> Jun 03, 2014 11:12:33 PM com.levigo.jbig2.util.log.JDKLogger error
> >>>
> >>> SEVERE: No global segment added so far.
> >>>
> >>> Jun 03, 2014 11:12:33 PM com.levigo.jbig2.util.log.JDKLogger error
> >>>
> >>> SEVERE: No global segment added so far.
> >>>
> >>> Jun 03, 2014 11:12:33 PM com.levigo.jbig2.util.log.JDKLogger error
> >>>
> >>> SEVERE: No global segment added so far.
> >>>
> >>> Jun 03, 2014 11:12:33 PM com.levigo.jbig2.util.log.JDKLogger error
> >>>
> >>> SEVERE: No global segment added so far.
> >>>
> >>>
> >>> On Wed, Jun 4, 2014 at 1:23 AM, Tilman Hausherr <THausherr@t-online.de
> >
> >>> wrote:
> >>>
> >>>> Put the levigo JBIG2 decoder in your class path
> >>>> https://code.google.com/p/jbig2-imageio/
> >>>>
> >>>> Tilman
> >>>>
> >>>> Am 03.06.2014 19:09, schrieb DImuthu Upeksha:
> >>>>
> >>>> [1]https://www.dropbox.com/s/ywscxm2n8pubat5/pdf3.pdf
> >>>>>
> >>>>> SEVERE: error while creating a xobject
> >>>>>
> >>>>> org.apache.pdfbox.filter.MissingImageReaderException: Cannot read
> JBIG2
> >>>>> image: jbig2-imageio is not installed
> >>>>>
> >>>>
> >>>>
> >>>
> >>>
> >>> --
> >>> Regards
> >>>
> >>> W.Dimuthu Upeksha
> >>> Undergraduate
> >>> Department of Computer Science And Engineering
> >>>
> >>> University of Moratuwa, Sri Lanka
> >>
> >>
> >
> >
> > --
> > Regards
> >
> > W.Dimuthu Upeksha
> > Undergraduate
> > Department of Computer Science And Engineering
> >
> > University of Moratuwa, Sri Lanka
>
>


-- 
Regards

W.Dimuthu Upeksha
Undergraduate
Department of Computer Science And Engineering

University of Moratuwa, Sri Lanka

Re: Problem with PDFRenderer

Posted by John Hewson <jo...@jahewson.com>.
Does the PDF render ok? If so, then ignore the error messages. PDFs often contain some corrupted data.
If not, try running the same code outside of a unit test - sometimes the test runner can cause problems.

If you’re still having problems, then just ignore this PDF, fixing JBIG2 bugs is not your problem right now :)

-- John

On 4 Jun 2014, at 08:12, DImuthu Upeksha <di...@gmail.com> wrote:

> John,
> I'm not sure about thread safe manner you have mentioned. How can I make it
> thread safe? I'm running only this unit test so I think it is not a problem
> with parallel test running.
> 
> 
> On Wed, Jun 4, 2014 at 9:20 AM, John Hewson <jo...@jahewson.com> wrote:
> 
>> It’s probably an issue with your unit test, are you running it in parallel
>> on in some non-thread-safe manner?
>> 
>> -- John
>> 
>> On 3 Jun 2014, at 10:46, DImuthu Upeksha <di...@gmail.com>
>> wrote:
>> 
>>> Hi Tilman,
>>> 
>>> Thank you for your quick response. I added jar to classpath but it gave
>>> same error, Then I updated my pom file with this
>>> https://code.google.com/p/jbig2-imageio/wiki/UsingMaven. Now exception
>>> didn't appear but it gives following error message
>>> 
>>> Jun 03, 2014 11:12:33 PM com.levigo.jbig2.util.log.JDKLogger info
>>> 
>>> INFO: JBIG2ReadParam not specified. Default will be used.
>>> 
>>> Jun 03, 2014 11:12:33 PM com.levigo.jbig2.util.log.JDKLogger info
>>> 
>>> INFO: Globals not set.
>>> 
>>> Jun 03, 2014 11:12:33 PM com.levigo.jbig2.util.log.JDKLogger error
>>> 
>>> SEVERE: No global segment added so far.
>>> 
>>> Jun 03, 2014 11:12:33 PM com.levigo.jbig2.util.log.JDKLogger error
>>> 
>>> SEVERE: No global segment added so far.
>>> 
>>> Jun 03, 2014 11:12:33 PM com.levigo.jbig2.util.log.JDKLogger error
>>> 
>>> SEVERE: No global segment added so far.
>>> 
>>> Jun 03, 2014 11:12:33 PM com.levigo.jbig2.util.log.JDKLogger error
>>> 
>>> SEVERE: No global segment added so far.
>>> 
>>> 
>>> On Wed, Jun 4, 2014 at 1:23 AM, Tilman Hausherr <TH...@t-online.de>
>>> wrote:
>>> 
>>>> Put the levigo JBIG2 decoder in your class path
>>>> https://code.google.com/p/jbig2-imageio/
>>>> 
>>>> Tilman
>>>> 
>>>> Am 03.06.2014 19:09, schrieb DImuthu Upeksha:
>>>> 
>>>> [1]https://www.dropbox.com/s/ywscxm2n8pubat5/pdf3.pdf
>>>>> 
>>>>> SEVERE: error while creating a xobject
>>>>> 
>>>>> org.apache.pdfbox.filter.MissingImageReaderException: Cannot read JBIG2
>>>>> image: jbig2-imageio is not installed
>>>>> 
>>>> 
>>>> 
>>> 
>>> 
>>> --
>>> Regards
>>> 
>>> W.Dimuthu Upeksha
>>> Undergraduate
>>> Department of Computer Science And Engineering
>>> 
>>> University of Moratuwa, Sri Lanka
>> 
>> 
> 
> 
> -- 
> Regards
> 
> W.Dimuthu Upeksha
> Undergraduate
> Department of Computer Science And Engineering
> 
> University of Moratuwa, Sri Lanka


Re: Problem with PDFRenderer

Posted by DImuthu Upeksha <di...@gmail.com>.
John,
I'm not sure about thread safe manner you have mentioned. How can I make it
thread safe? I'm running only this unit test so I think it is not a problem
with parallel test running.


On Wed, Jun 4, 2014 at 9:20 AM, John Hewson <jo...@jahewson.com> wrote:

> It’s probably an issue with your unit test, are you running it in parallel
> on in some non-thread-safe manner?
>
> -- John
>
> On 3 Jun 2014, at 10:46, DImuthu Upeksha <di...@gmail.com>
> wrote:
>
> > Hi Tilman,
> >
> > Thank you for your quick response. I added jar to classpath but it gave
> > same error, Then I updated my pom file with this
> > https://code.google.com/p/jbig2-imageio/wiki/UsingMaven. Now exception
> > didn't appear but it gives following error message
> >
> > Jun 03, 2014 11:12:33 PM com.levigo.jbig2.util.log.JDKLogger info
> >
> > INFO: JBIG2ReadParam not specified. Default will be used.
> >
> > Jun 03, 2014 11:12:33 PM com.levigo.jbig2.util.log.JDKLogger info
> >
> > INFO: Globals not set.
> >
> > Jun 03, 2014 11:12:33 PM com.levigo.jbig2.util.log.JDKLogger error
> >
> > SEVERE: No global segment added so far.
> >
> > Jun 03, 2014 11:12:33 PM com.levigo.jbig2.util.log.JDKLogger error
> >
> > SEVERE: No global segment added so far.
> >
> > Jun 03, 2014 11:12:33 PM com.levigo.jbig2.util.log.JDKLogger error
> >
> > SEVERE: No global segment added so far.
> >
> > Jun 03, 2014 11:12:33 PM com.levigo.jbig2.util.log.JDKLogger error
> >
> > SEVERE: No global segment added so far.
> >
> >
> > On Wed, Jun 4, 2014 at 1:23 AM, Tilman Hausherr <TH...@t-online.de>
> > wrote:
> >
> >> Put the levigo JBIG2 decoder in your class path
> >> https://code.google.com/p/jbig2-imageio/
> >>
> >> Tilman
> >>
> >> Am 03.06.2014 19:09, schrieb DImuthu Upeksha:
> >>
> >> [1]https://www.dropbox.com/s/ywscxm2n8pubat5/pdf3.pdf
> >>>
> >>> SEVERE: error while creating a xobject
> >>>
> >>> org.apache.pdfbox.filter.MissingImageReaderException: Cannot read JBIG2
> >>> image: jbig2-imageio is not installed
> >>>
> >>
> >>
> >
> >
> > --
> > Regards
> >
> > W.Dimuthu Upeksha
> > Undergraduate
> > Department of Computer Science And Engineering
> >
> > University of Moratuwa, Sri Lanka
>
>


-- 
Regards

W.Dimuthu Upeksha
Undergraduate
Department of Computer Science And Engineering

University of Moratuwa, Sri Lanka

Re: Problem with PDFRenderer

Posted by John Hewson <jo...@jahewson.com>.
It’s probably an issue with your unit test, are you running it in parallel on in some non-thread-safe manner?

-- John

On 3 Jun 2014, at 10:46, DImuthu Upeksha <di...@gmail.com> wrote:

> Hi Tilman,
> 
> Thank you for your quick response. I added jar to classpath but it gave
> same error, Then I updated my pom file with this
> https://code.google.com/p/jbig2-imageio/wiki/UsingMaven. Now exception
> didn't appear but it gives following error message
> 
> Jun 03, 2014 11:12:33 PM com.levigo.jbig2.util.log.JDKLogger info
> 
> INFO: JBIG2ReadParam not specified. Default will be used.
> 
> Jun 03, 2014 11:12:33 PM com.levigo.jbig2.util.log.JDKLogger info
> 
> INFO: Globals not set.
> 
> Jun 03, 2014 11:12:33 PM com.levigo.jbig2.util.log.JDKLogger error
> 
> SEVERE: No global segment added so far.
> 
> Jun 03, 2014 11:12:33 PM com.levigo.jbig2.util.log.JDKLogger error
> 
> SEVERE: No global segment added so far.
> 
> Jun 03, 2014 11:12:33 PM com.levigo.jbig2.util.log.JDKLogger error
> 
> SEVERE: No global segment added so far.
> 
> Jun 03, 2014 11:12:33 PM com.levigo.jbig2.util.log.JDKLogger error
> 
> SEVERE: No global segment added so far.
> 
> 
> On Wed, Jun 4, 2014 at 1:23 AM, Tilman Hausherr <TH...@t-online.de>
> wrote:
> 
>> Put the levigo JBIG2 decoder in your class path
>> https://code.google.com/p/jbig2-imageio/
>> 
>> Tilman
>> 
>> Am 03.06.2014 19:09, schrieb DImuthu Upeksha:
>> 
>> [1]https://www.dropbox.com/s/ywscxm2n8pubat5/pdf3.pdf
>>> 
>>> SEVERE: error while creating a xobject
>>> 
>>> org.apache.pdfbox.filter.MissingImageReaderException: Cannot read JBIG2
>>> image: jbig2-imageio is not installed
>>> 
>> 
>> 
> 
> 
> -- 
> Regards
> 
> W.Dimuthu Upeksha
> Undergraduate
> Department of Computer Science And Engineering
> 
> University of Moratuwa, Sri Lanka


Re: Problem with PDFRenderer

Posted by Tilman Hausherr <TH...@t-online.de>.
Hi,

Weird - I don't get the "severe" errors. I am using the 1.6.1 version of 
the levigo plugin and the latest version of PDFBox.

Tilman

Am 03.06.2014 19:46, schrieb DImuthu Upeksha:
> Hi Tilman,
>
> Thank you for your quick response. I added jar to classpath but it gave
> same error, Then I updated my pom file with this
> https://code.google.com/p/jbig2-imageio/wiki/UsingMaven. Now exception
> didn't appear but it gives following error message
>
> Jun 03, 2014 11:12:33 PM com.levigo.jbig2.util.log.JDKLogger info
>
> INFO: JBIG2ReadParam not specified. Default will be used.
>
> Jun 03, 2014 11:12:33 PM com.levigo.jbig2.util.log.JDKLogger info
>
> INFO: Globals not set.
>
> Jun 03, 2014 11:12:33 PM com.levigo.jbig2.util.log.JDKLogger error
>
> SEVERE: No global segment added so far.
>
> Jun 03, 2014 11:12:33 PM com.levigo.jbig2.util.log.JDKLogger error
>
> SEVERE: No global segment added so far.
>
> Jun 03, 2014 11:12:33 PM com.levigo.jbig2.util.log.JDKLogger error
>
> SEVERE: No global segment added so far.
>
> Jun 03, 2014 11:12:33 PM com.levigo.jbig2.util.log.JDKLogger error
>
> SEVERE: No global segment added so far.
>
>
> On Wed, Jun 4, 2014 at 1:23 AM, Tilman Hausherr <TH...@t-online.de>
> wrote:
>
>> Put the levigo JBIG2 decoder in your class path
>> https://code.google.com/p/jbig2-imageio/
>>
>> Tilman
>>
>> Am 03.06.2014 19:09, schrieb DImuthu Upeksha:
>>
>>   [1]https://www.dropbox.com/s/ywscxm2n8pubat5/pdf3.pdf
>>> SEVERE: error while creating a xobject
>>>
>>> org.apache.pdfbox.filter.MissingImageReaderException: Cannot read JBIG2
>>> image: jbig2-imageio is not installed
>>>
>>
>


Re: Problem with PDFRenderer

Posted by DImuthu Upeksha <di...@gmail.com>.
Hi Tilman,

Thank you for your quick response. I added jar to classpath but it gave
same error, Then I updated my pom file with this
https://code.google.com/p/jbig2-imageio/wiki/UsingMaven. Now exception
didn't appear but it gives following error message

Jun 03, 2014 11:12:33 PM com.levigo.jbig2.util.log.JDKLogger info

INFO: JBIG2ReadParam not specified. Default will be used.

Jun 03, 2014 11:12:33 PM com.levigo.jbig2.util.log.JDKLogger info

INFO: Globals not set.

Jun 03, 2014 11:12:33 PM com.levigo.jbig2.util.log.JDKLogger error

SEVERE: No global segment added so far.

Jun 03, 2014 11:12:33 PM com.levigo.jbig2.util.log.JDKLogger error

SEVERE: No global segment added so far.

Jun 03, 2014 11:12:33 PM com.levigo.jbig2.util.log.JDKLogger error

SEVERE: No global segment added so far.

Jun 03, 2014 11:12:33 PM com.levigo.jbig2.util.log.JDKLogger error

SEVERE: No global segment added so far.


On Wed, Jun 4, 2014 at 1:23 AM, Tilman Hausherr <TH...@t-online.de>
wrote:

> Put the levigo JBIG2 decoder in your class path
> https://code.google.com/p/jbig2-imageio/
>
> Tilman
>
> Am 03.06.2014 19:09, schrieb DImuthu Upeksha:
>
>  [1]https://www.dropbox.com/s/ywscxm2n8pubat5/pdf3.pdf
>>
>> SEVERE: error while creating a xobject
>>
>> org.apache.pdfbox.filter.MissingImageReaderException: Cannot read JBIG2
>> image: jbig2-imageio is not installed
>>
>
>


-- 
Regards

W.Dimuthu Upeksha
Undergraduate
Department of Computer Science And Engineering

University of Moratuwa, Sri Lanka

Re: Problem with PDFRenderer

Posted by Tilman Hausherr <TH...@t-online.de>.
Put the levigo JBIG2 decoder in your class path
https://code.google.com/p/jbig2-imageio/

Tilman

Am 03.06.2014 19:09, schrieb DImuthu Upeksha:
> [1]https://www.dropbox.com/s/ywscxm2n8pubat5/pdf3.pdf
>
> SEVERE: error while creating a xobject
>
> org.apache.pdfbox.filter.MissingImageReaderException: Cannot read JBIG2
> image: jbig2-imageio is not installed