Giter Site home page Giter Site logo

com.itextpdf.kernel.PdfException: Append mode requires a document without errors, even if recovery is possible about batchpdfsign HOT 9 CLOSED

jmarxuach avatar jmarxuach commented on May 29, 2024
com.itextpdf.kernel.PdfException: Append mode requires a document without errors, even if recovery is possible

from batchpdfsign.

Comments (9)

jmarxuach avatar jmarxuach commented on May 29, 2024

That's the exception

[main] ERROR com.itextpdf.kernel.pdf.PdfReader - Error occurred while reading cross reference table. Cross reference table will be rebuilt.
com.itextpdf.io.IOException: Error at file pointer 46,820.
at com.itextpdf.io.source.PdfTokenizer.throwError(PdfTokenizer.java:686)
at com.itextpdf.kernel.pdf.PdfReader.readXrefSection(PdfReader.java:1011)
at com.itextpdf.kernel.pdf.PdfReader.readXref(PdfReader.java:929)
at com.itextpdf.kernel.pdf.PdfReader.readPdf(PdfReader.java:677)
at com.itextpdf.kernel.pdf.PdfDocument.open(PdfDocument.java:1871)
at com.itextpdf.kernel.pdf.PdfDocument.(PdfDocument.java:324)
at com.itextpdf.signatures.PdfSigner.initDocument(PdfSigner.java:306)
at com.itextpdf.signatures.PdfSigner.(PdfSigner.java:288)
at com.itextpdf.signatures.PdfSigner.(PdfSigner.java:271)
at BatchPDFSign.lib.BatchPDFSign.signFile(BatchPDFSign.java:73)
at BatchPDFSign.portable.Main.main(Main.java:48)
Caused by: com.itextpdf.io.IOException: file position {0} cross reference entry in this xref subsection.
... 11 more
Exception in thread "main" com.itextpdf.kernel.PdfException: Append mode requires a document without errors, even if recovery is possible.
at com.itextpdf.kernel.pdf.PdfDocument.open(PdfDocument.java:1918)
at com.itextpdf.kernel.pdf.PdfDocument.(PdfDocument.java:324)
at com.itextpdf.signatures.PdfSigner.initDocument(PdfSigner.java:306)
at com.itextpdf.signatures.PdfSigner.(PdfSigner.java:288)
at com.itextpdf.signatures.PdfSigner.(PdfSigner.java:271)
at BatchPDFSign.lib.BatchPDFSign.signFile(BatchPDFSign.java:73)
at BatchPDFSign.portable.Main.main(Main.java:48)

from batchpdfsign.

Jocomol avatar Jocomol commented on May 29, 2024

I've tried it with the sample file supplied by the OP of the question, found here. Can you the file or some similar file?

The version of iText7 the OP used was 7.0.4, we use 7.1.11. So I think the bug would be fixed already.

from batchpdfsign.

jmarxuach avatar jmarxuach commented on May 29, 2024

I've tried it with the sample file supplied by the OP of the question, found here. Can you the file or some similar file?

The version of iText7 the OP used was 7.0.4, we use 7.1.11. So I think the bug would be fixed already.

I agree. Look, if I try to with following code

StampingProperties properties = new StampingProperties();

instead of

StampingProperties properties = new StampingProperties().preserveEncryption().useAppendMode();

It works !

I think useAppendModemode and preserveEncryption requires a document without errors, even if recovery is possible in itext7.

from batchpdfsign.

Jocomol avatar Jocomol commented on May 29, 2024

#7

from batchpdfsign.

Jocomol avatar Jocomol commented on May 29, 2024

I'll have to test if removing preserveEncyription() still works with PDF/A

from batchpdfsign.

Jocomol avatar Jocomol commented on May 29, 2024

@jmarxuach can you try out if version 1.0.5.1 works, because I only removed .useAppendMode().

from batchpdfsign.

jmarxuach avatar jmarxuach commented on May 29, 2024

@jmarxuach can you try out if version 1.0.5.1 works, because I only removed .useAppendMode().

It Works !! Even if prints the exception

[main] ERROR com.itextpdf.kernel.pdf.PdfReader - Error occurred while reading cross reference table. Cross reference table will be rebuilt.
com.itextpdf.io.IOException: Error at file pointer 46,820.
        at com.itextpdf.io.source.PdfTokenizer.throwError(PdfTokenizer.java:686)
        at com.itextpdf.kernel.pdf.PdfReader.readXrefSection(PdfReader.java:1011)
        at com.itextpdf.kernel.pdf.PdfReader.readXref(PdfReader.java:929)
        at com.itextpdf.kernel.pdf.PdfReader.readPdf(PdfReader.java:677)
        at com.itextpdf.kernel.pdf.PdfDocument.open(PdfDocument.java:1871)
        at com.itextpdf.kernel.pdf.PdfDocument.<init>(PdfDocument.java:324)
        at com.itextpdf.signatures.PdfSigner.initDocument(PdfSigner.java:306)
        at com.itextpdf.signatures.PdfSigner.<init>(PdfSigner.java:288)
        at com.itextpdf.signatures.PdfSigner.<init>(PdfSigner.java:271)
        at BatchPDFSign.lib.BatchPDFSign.signFile(BatchPDFSign.java:75)
        at BatchPDFSign.portable.Main.main(Main.java:48)
Caused by: com.itextpdf.io.IOException: file position {0} cross reference entry in this xref subsection.
        ... 11 more
[main] ERROR com.itextpdf.kernel.pdf.PdfReader - Error occurred while reading cross reference table. Cross reference table will be rebuilt.
com.itextpdf.io.IOException: Error at file pointer 46,820.
        at com.itextpdf.io.source.PdfTokenizer.throwError(PdfTokenizer.java:686)
        at com.itextpdf.kernel.pdf.PdfReader.readXrefSection(PdfReader.java:1011)
        at com.itextpdf.kernel.pdf.PdfReader.readXref(PdfReader.java:929)
        at com.itextpdf.kernel.pdf.PdfReader.readPdf(PdfReader.java:677)
        at com.itextpdf.kernel.pdf.PdfDocument.open(PdfDocument.java:1871)
        at com.itextpdf.kernel.pdf.PdfDocument.<init>(PdfDocument.java:324)
        at com.itextpdf.signatures.PdfSigner.initDocument(PdfSigner.java:306)
        at com.itextpdf.signatures.PdfSigner.<init>(PdfSigner.java:288)
        at com.itextpdf.signatures.PdfSigner.<init>(PdfSigner.java:271)
        at BatchPDFSign.lib.BatchPDFSign.signFile(BatchPDFSign.java:79)
        at BatchPDFSign.portable.Main.main(Main.java:48)
Caused by: com.itextpdf.io.IOException: file position {0} cross reference entry in this xref subsection.
        ... 11 more
[main] INFO com.itextpdf.signatures.TSAClientBouncyCastle - Timestamp generated: Thu Jul 23 14:54:01 CEST 2020

from batchpdfsign.

Jocomol avatar Jocomol commented on May 29, 2024

@jmarxuach your pdf file is probably damaged, can you try with a similar file?

from batchpdfsign.

jmarxuach avatar jmarxuach commented on May 29, 2024

@jmarxuach your pdf file is probably damaged, can you try with a similar file?

My Pdf file is 1,4 version and is created with https://wkhtmltopdf.org/ I can open it with acrobat reader DC and the signed PDF too.

Anyway, now BatchPDFSign works even if prints the exception. My PDF file is a worst case test. I have created a release v1.0.5.1

To me, issue is solved. May be I will open a new one to remember to solve the exception print.

from batchpdfsign.

Related Issues (15)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.