You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@pdfbox.apache.org by Patrycja Zaremba <pa...@schibsted.com.INVALID> on 2024/06/20 21:42:39 UTC
PDF to image conversion issue - Can't read the embedded Type1 font, found Token but expected ND
Hi,
I got this error when converting PDF to and image.
> *ERROR org.apache.pdfbox.pdmodel.font.PDType1Font -- Can't read the
> embedded Type1 font CJGKGJ+HelveticaAB-Halvfetjava.io.IOException: Found
> Token[kind=NAME, text=y→� ~$;VᄅoリᅱuᅩAb →→ !ᅰᄐe�ᅩwロᄂニDᆳ"i ハ.] but
> expected ND*
> at org.apache.fontbox.type1.Type1Parser.readDef(Type1Parser.java:839)
> at
> org.apache.fontbox.type1.Type1Parser.readCharStrings(Type1Parser.java:804)
> at org.apache.fontbox.type1.Type1Parser.parseBinary(Type1Parser.java:647)
> at org.apache.fontbox.type1.Type1Parser.parse(Type1Parser.java:71)
> at org.apache.fontbox.type1.Type1Font.createWithSegments(Type1Font.java:85)
> at org.apache.pdfbox.pdmodel.font.PDType1Font.<init>(PDType1Font.java:243)
> at
> org.apache.pdfbox.pdmodel.font.PDFontFactory.createFont(PDFontFactory.java:140)
> at org.apache.pdfbox.pdmodel.PDResources.getFont(PDResources.java:170)
> at
> org.apache.pdfbox.contentstream.operator.text.SetFontAndSize.process(SetFontAndSize.java:72)
> at
> org.apache.pdfbox.contentstream.PDFStreamEngine.processOperator(PDFStreamEngine.java:893)
> at
> org.apache.pdfbox.contentstream.PDFStreamEngine.processStreamOperators(PDFStreamEngine.java:531)
> at
> org.apache.pdfbox.contentstream.PDFStreamEngine.processStream(PDFStreamEngine.java:506)
> at
> org.apache.pdfbox.contentstream.PDFStreamEngine.processPage(PDFStreamEngine.java:153)
> at org.apache.pdfbox.rendering.PageDrawer.drawPage(PageDrawer.java:286)
> at
> org.apache.pdfbox.rendering.PDFRenderer.renderImage(PDFRenderer.java:330)
> at
> org.apache.pdfbox.rendering.PDFRenderer.renderImage(PDFRenderer.java:247)
> at
> org.apache.pdfbox.rendering.PDFRenderer.renderImageWithDPI(PDFRenderer.java:219)
>
PDFBox version 3.0.2.
Is this an issue with PDF itself or the library?
Here is example of problematic PDF:
https://mega.nz/file/osthCK6Q#UVoaV75ExP9ro_x2hNvbP3xEmK-tkZja3eiwG7S8Ilc
Best regards,
Patrycja Zaremba
Re: PDF to JPEG conversion process is hanging infinitely for PDF with many (~17k) objects
Posted by Tilman Hausherr <TH...@t-online.de>.
It's likely similar to
https://issues.apache.org/jira/browse/PDFBOX-4718 see also the JDK bug
reports.
Tilman
On 20.08.2024 12:25, Tilman Hausherr wrote:
> It hasn't finished here, wow. I tried with different versions, also
> older ones. In the meantime I found out that it's not just the 44629
> images, but also 38 patterns, and some of them have over 100 images,
> some are shading patterns. I have created
> https://issues.apache.org/jira/browse/PDFBOX-5871 but I have no idea
> what to do.
>
> Tilman
>
> On 19.08.2024 11:08, Tilman Hausherr wrote:
>> 44629... lets see what happens.
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
> For additional commands, e-mail: users-help@pdfbox.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org
Re: PDF to JPEG conversion process is hanging infinitely for PDF with many (~17k) objects
Posted by Tilman Hausherr <TH...@t-online.de>.
It hasn't finished here, wow. I tried with different versions, also
older ones. In the meantime I found out that it's not just the 44629
images, but also 38 patterns, and some of them have over 100 images,
some are shading patterns. I have created
https://issues.apache.org/jira/browse/PDFBOX-5871 but I have no idea
what to do.
Tilman
On 19.08.2024 11:08, Tilman Hausherr wrote:
> 44629... lets see what happens.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org
Re: PDF to JPEG conversion process is hanging infinitely for PDF with many (~17k) objects
Posted by Tilman Hausherr <TH...@t-online.de>.
44629... lets see what happens.
Tilman
On 19.08.2024 11:01, Patrycja Zaremba wrote:
> Hi!
>
> I have an issue, that I'm unable to render JPEG image from PDF which looks
> correct (it opens in Adobe Acrobat Reader without any warnings etc.), but
> the only distinctive thing I found about it is that it contains of really a
> lot of images/objects - 17036/17447.
>
> The process never ends for it (I waited 24h).
> Tested on PDFBox 3.0.3.
> Here is the file:
> https://mega.nz/file/V1USEQTD#nlKGVi0TgQ9M1bQc_44Y8dZ_Zpdy_ZcZUc0j4ug94ic
>
> Best regards,
>
> Patrycja Zaremba
>
PDF to JPEG conversion process is hanging infinitely for PDF with many (~17k) objects
Posted by Patrycja Zaremba <pa...@schibsted.com.INVALID>.
Hi!
I have an issue, that I'm unable to render JPEG image from PDF which looks
correct (it opens in Adobe Acrobat Reader without any warnings etc.), but
the only distinctive thing I found about it is that it contains of really a
lot of images/objects - 17036/17447.
The process never ends for it (I waited 24h).
Tested on PDFBox 3.0.3.
Here is the file:
https://mega.nz/file/V1USEQTD#nlKGVi0TgQ9M1bQc_44Y8dZ_Zpdy_ZcZUc0j4ug94ic
Best regards,
Patrycja Zaremba
Re: java.lang.IllegalArgumentException: capacity < 0: (-2115587440 <0)
Posted by Patrycja Zaremba <pa...@schibsted.com.INVALID>.
Sorry for topic confusion! I tried it on 3.0.3-SNAPSHOT and indeed it
worked! Thank you :) Best regards,Patrycja Zaremba
Re: java.lang.IllegalArgumentException: capacity < 0: (-2115587440 <0)
Posted by Tilman Hausherr <TH...@t-online.de>.
Hello Patrycja,
I managed to download that file. Text extraction works with 3.0.3, but
not with 3.0.2 because the content stream is huge. The problem you
mentioned was indeed fixed, I remember that it was a similar problem.
Probably PDFBOX-5675 which was related to the file from PDFBOX-3712.
Tilman
On 05.08.2024 16:42, Tilman Hausherr wrote:
> Hello Patrycja,
>
> Please try with a snapshot while I download the file:
> https://repository.apache.org/content/groups/snapshots/org/apache/pdfbox/pdfbox-app/3.0.3-SNAPSHOT/
>
>
> Tilman
>
> PS: please create a new thread, answering / responding to an old topic
> is confusing
>
>
> On 05.08.2024 15:31, Patrycja Zaremba wrote:
>> Hi!
>> I have a specific PDF file which is very heavy (more than 1GB) and I'm
>> trying to scrap text from it, but getting this error:
>>
>> Caused by: java.lang.IllegalArgumentException: capacity < 0:
>> (-2115587440 <
>>> 0)
>>> at java.base/java.nio.Buffer.createCapacityException(Buffer.java:290)
>>> ~[na:na]
>>> at java.base/java.nio.ByteBuffer.allocate(ByteBuffer.java:390) ~[na:na]
>>> at
>>> org.apache.pdfbox.io.RandomAccessReadBuffer.<init>(RandomAccessReadBuffer.java:70)
>>>
>>> ~[pdfbox-io-3.0.2.jar!/:3.0.2]
>>> at
>>> org.apache.pdfbox.io.RandomAccessReadWriteBuffer.<init>(RandomAccessReadWriteBuffer.java:40)
>>>
>>> ~[pdfbox-io-3.0.2.jar!/:3.0.2]
>>> at org.apache.pdfbox.filter.Filter.decode(Filter.java:250)
>>> ~[pdfbox-3.0.2.jar!/:3.0.2]
>>> at org.apache.pdfbox.cos.COSStream.createView(COSStream.java:196)
>>> ~[pdfbox-3.0.2.jar!/:3.0.2]
>>> at
>>> org.apache.pdfbox.pdmodel.PDPage.getContentsForRandomAccess(PDPage.java:177)
>>>
>>> ~[pdfbox-3.0.2.jar!/:3.0.2]
>>> at
>>> org.apache.pdfbox.pdfparser.PDFStreamParser.<init>(PDFStreamParser.java:59)
>>>
>>> ~[pdfbox-3.0.2.jar!/:3.0.2]
>>> at
>>> org.apache.pdfbox.contentstream.PDFStreamEngine.processStreamOperators(PDFStreamEngine.java:525)
>>>
>>> ~[pdfbox-3.0.2.jar!/:3.0.2]
>>> at
>>> org.apache.pdfbox.contentstream.PDFStreamEngine.processStream(PDFStreamEngine.java:506)
>>>
>>> ~[pdfbox-3.0.2.jar!/:3.0.2]
>>> at
>>> org.apache.pdfbox.contentstream.PDFStreamEngine.processPage(PDFStreamEngine.java:153)
>>>
>>> ~[pdfbox-3.0.2.jar!/:3.0.2]
>>> at
>>> org.apache.pdfbox.text.LegacyPDFStreamEngine.processPage(LegacyPDFStreamEngine.java:153)
>>>
>>> ~[pdfbox-3.0.2.jar!/:3.0.2]
>>> at
>>> org.apache.pdfbox.text.PDFTextStripper.processPage(PDFTextStripper.java:362)
>>>
>>> ~[pdfbox-3.0.2.jar!/:3.0.2]
>>> at
>>> org.apache.pdfbox.text.PDFTextStripper.processPages(PDFTextStripper.java:288)
>>>
>>> ~[pdfbox-3.0.2.jar!/:3.0.2]
>>> at
>>> org.apache.pdfbox.text.PDFTextStripper.writeText(PDFTextStripper.java:235)
>>>
>>> ~[pdfbox-3.0.2.jar!/:3.0.2]
>>
>> I'm wondering if it's possible to somehow make it running or is it not
>> supported?
>>
>> Here is the problematic file:
>> https://mega.nz/file/NscTmJSL#Bp4TL4UjqUqgMykNO_f7j33y3n0Zwy12K7fNr45GYF8
>>
>> I opened it with Acrobat Reader, it doesn't look like corrupted. It
>> loads
>> significantly long, but finally I am able to select text there etc.
>>
>> Best regards,
>>
>> Patrycja Zaremba
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
> For additional commands, e-mail: users-help@pdfbox.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org
Re: java.lang.IllegalArgumentException: capacity < 0: (-2115587440 <0)
Posted by Tilman Hausherr <TH...@t-online.de>.
Hello Patrycja,
Please try with a snapshot while I download the file:
https://repository.apache.org/content/groups/snapshots/org/apache/pdfbox/pdfbox-app/3.0.3-SNAPSHOT/
Tilman
PS: please create a new thread, answering / responding to an old topic
is confusing
On 05.08.2024 15:31, Patrycja Zaremba wrote:
> Hi!
> I have a specific PDF file which is very heavy (more than 1GB) and I'm
> trying to scrap text from it, but getting this error:
>
> Caused by: java.lang.IllegalArgumentException: capacity < 0: (-2115587440 <
>> 0)
>> at java.base/java.nio.Buffer.createCapacityException(Buffer.java:290)
>> ~[na:na]
>> at java.base/java.nio.ByteBuffer.allocate(ByteBuffer.java:390) ~[na:na]
>> at
>> org.apache.pdfbox.io.RandomAccessReadBuffer.<init>(RandomAccessReadBuffer.java:70)
>> ~[pdfbox-io-3.0.2.jar!/:3.0.2]
>> at
>> org.apache.pdfbox.io.RandomAccessReadWriteBuffer.<init>(RandomAccessReadWriteBuffer.java:40)
>> ~[pdfbox-io-3.0.2.jar!/:3.0.2]
>> at org.apache.pdfbox.filter.Filter.decode(Filter.java:250)
>> ~[pdfbox-3.0.2.jar!/:3.0.2]
>> at org.apache.pdfbox.cos.COSStream.createView(COSStream.java:196)
>> ~[pdfbox-3.0.2.jar!/:3.0.2]
>> at
>> org.apache.pdfbox.pdmodel.PDPage.getContentsForRandomAccess(PDPage.java:177)
>> ~[pdfbox-3.0.2.jar!/:3.0.2]
>> at
>> org.apache.pdfbox.pdfparser.PDFStreamParser.<init>(PDFStreamParser.java:59)
>> ~[pdfbox-3.0.2.jar!/:3.0.2]
>> at
>> org.apache.pdfbox.contentstream.PDFStreamEngine.processStreamOperators(PDFStreamEngine.java:525)
>> ~[pdfbox-3.0.2.jar!/:3.0.2]
>> at
>> org.apache.pdfbox.contentstream.PDFStreamEngine.processStream(PDFStreamEngine.java:506)
>> ~[pdfbox-3.0.2.jar!/:3.0.2]
>> at
>> org.apache.pdfbox.contentstream.PDFStreamEngine.processPage(PDFStreamEngine.java:153)
>> ~[pdfbox-3.0.2.jar!/:3.0.2]
>> at
>> org.apache.pdfbox.text.LegacyPDFStreamEngine.processPage(LegacyPDFStreamEngine.java:153)
>> ~[pdfbox-3.0.2.jar!/:3.0.2]
>> at
>> org.apache.pdfbox.text.PDFTextStripper.processPage(PDFTextStripper.java:362)
>> ~[pdfbox-3.0.2.jar!/:3.0.2]
>> at
>> org.apache.pdfbox.text.PDFTextStripper.processPages(PDFTextStripper.java:288)
>> ~[pdfbox-3.0.2.jar!/:3.0.2]
>> at
>> org.apache.pdfbox.text.PDFTextStripper.writeText(PDFTextStripper.java:235)
>> ~[pdfbox-3.0.2.jar!/:3.0.2]
>
> I'm wondering if it's possible to somehow make it running or is it not
> supported?
>
> Here is the problematic file:
> https://mega.nz/file/NscTmJSL#Bp4TL4UjqUqgMykNO_f7j33y3n0Zwy12K7fNr45GYF8
> I opened it with Acrobat Reader, it doesn't look like corrupted. It loads
> significantly long, but finally I am able to select text there etc.
>
> Best regards,
>
> Patrycja Zaremba
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org
Re: PDF to image conversion issue - Can't read the embedded Type1 font, found Token but expected ND
Posted by Patrycja Zaremba <pa...@schibsted.com.INVALID>.
Hi!
I have a specific PDF file which is very heavy (more than 1GB) and I'm
trying to scrap text from it, but getting this error:
Caused by: java.lang.IllegalArgumentException: capacity < 0: (-2115587440 <
> 0)
> at java.base/java.nio.Buffer.createCapacityException(Buffer.java:290)
> ~[na:na]
> at java.base/java.nio.ByteBuffer.allocate(ByteBuffer.java:390) ~[na:na]
> at
> org.apache.pdfbox.io.RandomAccessReadBuffer.<init>(RandomAccessReadBuffer.java:70)
> ~[pdfbox-io-3.0.2.jar!/:3.0.2]
> at
> org.apache.pdfbox.io.RandomAccessReadWriteBuffer.<init>(RandomAccessReadWriteBuffer.java:40)
> ~[pdfbox-io-3.0.2.jar!/:3.0.2]
> at org.apache.pdfbox.filter.Filter.decode(Filter.java:250)
> ~[pdfbox-3.0.2.jar!/:3.0.2]
> at org.apache.pdfbox.cos.COSStream.createView(COSStream.java:196)
> ~[pdfbox-3.0.2.jar!/:3.0.2]
> at
> org.apache.pdfbox.pdmodel.PDPage.getContentsForRandomAccess(PDPage.java:177)
> ~[pdfbox-3.0.2.jar!/:3.0.2]
> at
> org.apache.pdfbox.pdfparser.PDFStreamParser.<init>(PDFStreamParser.java:59)
> ~[pdfbox-3.0.2.jar!/:3.0.2]
> at
> org.apache.pdfbox.contentstream.PDFStreamEngine.processStreamOperators(PDFStreamEngine.java:525)
> ~[pdfbox-3.0.2.jar!/:3.0.2]
> at
> org.apache.pdfbox.contentstream.PDFStreamEngine.processStream(PDFStreamEngine.java:506)
> ~[pdfbox-3.0.2.jar!/:3.0.2]
> at
> org.apache.pdfbox.contentstream.PDFStreamEngine.processPage(PDFStreamEngine.java:153)
> ~[pdfbox-3.0.2.jar!/:3.0.2]
> at
> org.apache.pdfbox.text.LegacyPDFStreamEngine.processPage(LegacyPDFStreamEngine.java:153)
> ~[pdfbox-3.0.2.jar!/:3.0.2]
> at
> org.apache.pdfbox.text.PDFTextStripper.processPage(PDFTextStripper.java:362)
> ~[pdfbox-3.0.2.jar!/:3.0.2]
> at
> org.apache.pdfbox.text.PDFTextStripper.processPages(PDFTextStripper.java:288)
> ~[pdfbox-3.0.2.jar!/:3.0.2]
> at
> org.apache.pdfbox.text.PDFTextStripper.writeText(PDFTextStripper.java:235)
> ~[pdfbox-3.0.2.jar!/:3.0.2]
I'm wondering if it's possible to somehow make it running or is it not
supported?
Here is the problematic file:
https://mega.nz/file/NscTmJSL#Bp4TL4UjqUqgMykNO_f7j33y3n0Zwy12K7fNr45GYF8
I opened it with Acrobat Reader, it doesn't look like corrupted. It loads
significantly long, but finally I am able to select text there etc.
Best regards,
Patrycja Zaremba
On Thu, 20 Jun 2024 at 23:42, Patrycja Zaremba <
patrycja.zaremba@schibsted.com> wrote:
> Hi,
> I got this error when converting PDF to and image.
>
>
>> *ERROR org.apache.pdfbox.pdmodel.font.PDType1Font -- Can't read the
>> embedded Type1 font CJGKGJ+HelveticaAB-Halvfetjava.io.IOException: Found
>> Token[kind=NAME, text=y→� ~$;VᄅoリᅱuᅩAb →→ !ᅰᄐe�ᅩwロᄂニDᆳ"i ハ.] but
>> expected ND*
>> at org.apache.fontbox.type1.Type1Parser.readDef(Type1Parser.java:839)
>> at
>> org.apache.fontbox.type1.Type1Parser.readCharStrings(Type1Parser.java:804)
>> at org.apache.fontbox.type1.Type1Parser.parseBinary(Type1Parser.java:647)
>> at org.apache.fontbox.type1.Type1Parser.parse(Type1Parser.java:71)
>> at
>> org.apache.fontbox.type1.Type1Font.createWithSegments(Type1Font.java:85)
>> at org.apache.pdfbox.pdmodel.font.PDType1Font.<init>(PDType1Font.java:243)
>> at
>> org.apache.pdfbox.pdmodel.font.PDFontFactory.createFont(PDFontFactory.java:140)
>> at org.apache.pdfbox.pdmodel.PDResources.getFont(PDResources.java:170)
>> at
>> org.apache.pdfbox.contentstream.operator.text.SetFontAndSize.process(SetFontAndSize.java:72)
>> at
>> org.apache.pdfbox.contentstream.PDFStreamEngine.processOperator(PDFStreamEngine.java:893)
>> at
>> org.apache.pdfbox.contentstream.PDFStreamEngine.processStreamOperators(PDFStreamEngine.java:531)
>> at
>> org.apache.pdfbox.contentstream.PDFStreamEngine.processStream(PDFStreamEngine.java:506)
>> at
>> org.apache.pdfbox.contentstream.PDFStreamEngine.processPage(PDFStreamEngine.java:153)
>> at org.apache.pdfbox.rendering.PageDrawer.drawPage(PageDrawer.java:286)
>> at
>> org.apache.pdfbox.rendering.PDFRenderer.renderImage(PDFRenderer.java:330)
>> at
>> org.apache.pdfbox.rendering.PDFRenderer.renderImage(PDFRenderer.java:247)
>> at
>> org.apache.pdfbox.rendering.PDFRenderer.renderImageWithDPI(PDFRenderer.java:219)
>>
>
> PDFBox version 3.0.2.
>
> Is this an issue with PDF itself or the library?
> Here is example of problematic PDF:
> https://mega.nz/file/osthCK6Q#UVoaV75ExP9ro_x2hNvbP3xEmK-tkZja3eiwG7S8Ilc
>
> Best regards,
>
> Patrycja Zaremba
>
Re: PDF to image conversion issue - Can't read the embedded Type1 font, found Token but expected ND
Posted by Tilman Hausherr <TH...@t-online.de>.
On 20.06.2024 23:42, Patrycja Zaremba wrote:
> Is this an issue with PDF itself or the library?
> Here is example of problematic PDF:
> https://mega.nz/file/osthCK6Q#UVoaV75ExP9ro_x2hNvbP3xEmK-tkZja3eiwG7S8Ilc
Hi,
PDFBox fails to parse that type 1 font, but it recovers and uses a local
font:
Using fallback font ArialMT for CJGKGJ+HelveticaAB-Halvfet
About the parse error... it mentions garbled text, but I looked into the
uncompressed font text and I see a lot of complex PostScript, of which
we interpret only a subset (which works for almost all type 1 fonts). So
I wonder if the parser gets thrown off the rails much earlier already.
The end of the font file looks suspicious. FontForge is able to display
the font but brings up several warnings.
Anyway, the rendering looks good. PDF.js fails to render the font
("Aftonbladet" top right, and "Snacka..." begin of article). Chrome
succeeds. Adobe complains, and fails to display the part. Considering
that Adobe is the gold standard, I'd say your PDF is to blame.
Tilman