Look at PdfReader.isRebuilt() to look for errors. To sign in append mode this
must return false.
Paulo
> -----Original Message-----
> From: Gerrit Germis [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, October 07, 2008 9:40 AM
> To: Post all your questions about iText here
> Subject: [iText-questions] itext 1.4.2 sporadic exceptions
>
> Hi,
>
> Versions used:
> iText: 1.4.2
> java: 1.5.0_14
>
> To sign files, I'm basically using this snippet:
>
> reader = new PdfReader(new
> RandomAccessFileOrArray(file.getInputFile().getPath()), null);
> PdfStamper stp = PdfStamper.createSignature(reader, new
> FileOutputStream(file.getOutputFile()), '\0', this.tempFile, true);
> PdfSignatureAppearance sap = stp.getSignatureAppearance();
> sap.setCrypto(null, this.getToken().getCertificateChain(), null,
> PdfSignatureAppearance.WINCER_SIGNED);
> sap.setExternalDigest(new byte[128], new byte[20], "RSA");
> if (file.getSettings().needsCertification()) {
> sap.setCertified(true);
> }
>
> but am experiencing problems with it every now and then. The signing
> is done in a batch process, processing thousands of documents a day,
> but every now and then I get one of the folowing 2 exceptions:
>
>
> "Append mode requires a document without errors even if
> recovery was possible.":
>
> Oct 6 13:39:14 app02 2008-10-06 13:39:14,640 Finalizer-1 ERROR
> (PDFFileSigner:102) - 7810588_WEBPOST_93931544_36512821_(zzz document
> owner) Problem while signing QueuedFile [in:
> '/var/um/archive/236/200810/xyz.pdf', out:
> '/usr/local/um/server/temp/archive/236/200810/xyz.pdf', settings:
> (timestamp: true, certify: false,
> alias: default, reason: 'Approved', token: JDBCTOKEN)]: Append mode
> requires a document without errors even if recovery was possible.
> Oct 6 13:39:14 app02 com.lowagie.text.DocumentException: Append mode
> requires a document without errors even if recovery was possible.
> Oct 6 13:39:14 app02 at
> com.lowagie.text.pdf.PdfStamperImp.<init>(Unknown Source)
> Oct 6 13:39:14 app02 at
> com.lowagie.text.pdf.PdfStamper.<init>(Unknown Source)
> Oct 6 13:39:14 app02 at
> com.lowagie.text.pdf.PdfStamper.createSignature(Unknown Source)
>
> or
>
> "Invalid object number. at file pointer 2931"
>
> Oct 6 13:43:32 app02 2008-10-06 13:43:32,193 Finalizer-2 ERROR
> (PDFFileSigner:102) - 7812133_WEBPOST_93934810_36515796_(zzz document
> owner)
> Problem while signing QueuedFile [in:
> '/var/um/archive/236/200810/abc.pdf', out:
> '/usr/local/um/server/temp/archive/236/200810/abc.pdf', settings:
> (timestamp: true, certify: false,
> alias: default, reason: 'Approved', token: JDBCTOKEN)]: Invalid object
> number. at file pointer 2931 Oct 6 13:43:32 app02 Oct 6 13:43:32
> app02 2008-10-06 13:43:32,194 Finalizer-2 ERROR (FinalizerAction:77) -
> 7812133_WEBPOST_93934810_36515796_(Lampiris document owner)
> signItem()
> Oct 6 13:43:32 app02 java.lang.StringIndexOutOfBoundsException:
> String index out of range: -1
> Oct 6 13:43:32 app02 at
> java.lang.String.substring(String.java:1768)
> Oct 6 13:43:32 app02 at
> java.lang.String.substring(String.java:1735)
> Oct 6 13:43:32 app02 at
> org.apache.log4j.net.SyslogAppender.append(SyslogAppender.java:254)
> Oct 6 13:43:32 app02 at
> org.apache.log4j.AppenderSkeleton.doAppend(AppenderSkeleton.java:221)
> Oct 6 13:43:32 app02 at
> org.apache.log4j.helpers.AppenderAttachableImpl.appendLoopOnAp
> penders(AppenderAttachableImpl.java:57)
> Oct 6 13:43:32 app02 at
> org.apache.log4j.Category.callAppenders(Category.java:187)
> Oct 6 13:43:32 app02 at
> org.apache.log4j.Category.forcedLog(Category.java:372)
> Oct 6 13:43:32 app02 at
> org.apache.log4j.Category.log(Category.java:864)
>
>
> I copied the PDF files from the system and tried signing them again,
> and I get no errors anymore. Have any of you seen these errors before
> and know where I should be looking at? Is there a tool i can use to
> inspect the well-formedness of the PDF files?
>
>
> Sincerely,
>
> Gerrit
Aviso Legal:
Esta mensagem é destinada exclusivamente ao destinatário. Pode conter
informação confidencial ou legalmente protegida. A incorrecta transmissão desta
mensagem não significa a perca de confidencialidade. Se esta mensagem for
recebida por engano, por favor envie-a de volta para o remetente e apague-a do
seu sistema de imediato. É proibido a qualquer pessoa que não o destinatário de
usar, revelar ou distribuir qualquer parte desta mensagem.
Disclaimer:
This message is destined exclusively to the intended receiver. It may contain
confidential or legally protected information. The incorrect transmission of
this message does not mean the loss of its confidentiality. If this message is
received by mistake, please send it back to the sender and delete it from your
system immediately. It is forbidden to any person who is not the intended
receiver to use, distribute or copy any part of this message.
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
iText-questions mailing list
iText-questions@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/itext-questions
Buy the iText book: http://www.1t3xt.com/docs/book.php