You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pdfbox.apache.org by "Sumit Saha (JIRA)" <ji...@apache.org> on 2015/11/16 14:03:10 UTC

[jira] [Commented] (PDFBOX-2976) java.util.zip.DataFormatException: incorrect data check

    [ https://issues.apache.org/jira/browse/PDFBOX-2976?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15006637#comment-15006637 ] 

Sumit Saha commented on PDFBOX-2976:
------------------------------------

Hi Everyone,
I have been following PDFBox releated discussion for long and i have a better fix in my mind in which there would be no data loss.

The exception "incorrect data check" arises due to adler-32 checksum computation failure or corrupted stream.
Adler-32 Checksum can fail due to change in byteorder of last 4 bytes in the stream from Big Endian to Little Endian.
So what can be done is to bypass adler-32 check whcih would allow to extract all the data in the stream using inflaterinputstream.

To do so from code point of view , before making InflaterInputStream object, do this

inStm.skip(2); // here inStm is the object corresponding to the raw stream
Inflater inf = new Inflater(true); // the argument true corresponds to the option NoWrap turning it true would disable checksum computation.

Then create the object for InflaterInputStream ifis = new InflaterInputStream(inStm, inf);

Moreover the skipping first two bytes is required and those two bytes corresponds to Zlib header which are not required when adler-32 check needs to be bypassed.

Using this logic, even small data loss could be avoided.

> java.util.zip.DataFormatException: incorrect data check
> -------------------------------------------------------
>
>                 Key: PDFBOX-2976
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-2976
>             Project: PDFBox
>          Issue Type: Bug
>          Components: Parsing
>    Affects Versions: 2.0.0
>         Environment: Linux Mint 17.2 x64, JDK7u79, Glassfish 3.1.2.2
>            Reporter: Felix Rudolphi
>            Assignee: Andreas Lehmkühler
>             Fix For: 1.8.11, 2.0.0
>
>         Attachments: 500 ml (500.0) - Bisomer® MPEG350MA - 26915-72-0 - IVW_ 444 Oberflächentechnik.pdf, PDFBOX2976_FlateFilter2.patch, sc-356376(1)-x.pdf, sc-356376(1).pdf, sc-356376-x.pdf, sc-356376.pdf
>
>   Original Estimate: 3h
>  Remaining Estimate: 3h
>
> When trying to open certain PDF files (examples attached, also any MSDS available at http://www.scbt.com/datasheet-356376.html ), an expection is thrown resulting in the file not being parsed:
> java.io.IOException: java.util.zip.DataFormatException: incorrect data check
> 	at org.apache.pdfbox.filter.FlateFilter.decode(FlateFilter.java:83)
> 	at org.apache.pdfbox.cos.COSInputStream.create(COSInputStream.java:78)
> 	at org.apache.pdfbox.cos.COSStream.createInputStream(COSStream.java:160)
> 	at org.apache.pdfbox.cos.COSStream.getUnfilteredStream(COSStream.java:143)
> 	at org.apache.pdfbox.pdmodel.PDPage.getContents(PDPage.java:148)
> 	at org.apache.pdfbox.pdfparser.PDFStreamParser.<init>(PDFStreamParser.java:92)
> 	at org.apache.pdfbox.contentstream.PDFStreamEngine.processStreamOperators(PDFStreamEngine.java:450)
> 	at org.apache.pdfbox.contentstream.PDFStreamEngine.processStream(PDFStreamEngine.java:437)
> 	at org.apache.pdfbox.contentstream.PDFStreamEngine.processPage(PDFStreamEngine.java:148)
> 	at org.apache.pdfbox.text.PDFTextStreamEngine.processPage(PDFTextStreamEngine.java:117)
> 	at org.apache.pdfbox.text.PDFTextStripper.processPage(PDFTextStripper.java:367)
> 	at org.apache.pdfbox.text.PDFTextStripper.processPages(PDFTextStripper.java:303)
> 	at org.apache.pdfbox.text.PDFTextStripper.writeText(PDFTextStripper.java:248)
> 	at org.apache.pdfbox.text.PDFTextStripper.getText(PDFTextStripper.java:209)
> -- or --
> java.io.IOException: java.util.zip.DataFormatException: incorrect data check
> 	at org.apache.pdfbox.filter.FlateFilter.decode(FlateFilter.java:83)
> 	at org.apache.pdfbox.cos.COSInputStream.create(COSInputStream.java:78)
> 	at org.apache.pdfbox.cos.COSStream.createInputStream(COSStream.java:160)
> 	at org.apache.pdfbox.cos.COSStream.getUnfilteredStream(COSStream.java:143)
> 	at org.apache.pdfbox.pdmodel.PDPage.getContents(PDPage.java:148)
> 	at org.apache.pdfbox.pdfparser.PDFStreamParser.<init>(PDFStreamParser.java:92)
> 	at org.apache.pdfbox.contentstream.PDFStreamEngine.processStreamOperators(PDFStreamEngine.java:450)
> 	at org.apache.pdfbox.contentstream.PDFStreamEngine.processStream(PDFStreamEngine.java:437)
> 	at org.apache.pdfbox.contentstream.PDFStreamEngine.processPage(PDFStreamEngine.java:148)
> 	at org.apache.pdfbox.rendering.PageDrawer.drawPage(PageDrawer.java:179)
> 	at org.apache.pdfbox.rendering.PDFRenderer.renderPage(PDFRenderer.java:205)
> 	at org.apache.pdfbox.rendering.PDFRenderer.renderImage(PDFRenderer.java:136)



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: dev-help@pdfbox.apache.org