Hi, I'm trying to remove a signature from the attached sample PDF with itextpdf 5.5.8 and save the result in another file using this java code:
Provider provider = new BouncyCastleProvider();
Security.addProvider(provider);
PdfReader reader = new PdfReader(inputStream,
null);
AcroFields af = reader.getAcroFields();
ArrayList<String> names = af.getSignatureNames();
for (String name : names) {
System.out.println("Signature name: " +
name);
System.out.println("Signature covers whole
document: " + af.signatureCoversWholeDocument(name));
PdfPKCS7 pk = af.verifySignature(name,
provider.getName());
System.out.println("SignatureDate: " +
pk.getSignDate());
System.out.println("Certificate: " +
pk.getSigningCertificate());
System.out.println("Document modified: " +
!pk.verify());
af.removeField(name);
}
PdfStamper stamper = new PdfStamper(reader,
outputStream, '\0');
stamper.close();
But I have this exception in removeField:
Exception in thread "main" java.lang.NullPointerException
at com.itextpdf.text.pdf.AcroFields.removeField(AcroFields.java:1814)
at com.itextpdf.text.pdf.AcroFields.removeField(AcroFields.java:1854)
at securityframe.cms.VerificaFirmaCerta.verify(VerificaFirmaCerta.java:47)
at securityframe.cms.VerificaFirmaCerta.main(VerificaFirmaCerta.java:67)
The attached file is signed with FirmaCerta (a italian sw).
Anyone can help me? There is a bug in the signature sw or in the itext library?
Thanks in advance.
Alfonso
AVVISO DI RISERVATEZZA Informazioni riservate possono essere contenute nel
messaggio o nei suoi allegati. Se non siete i destinatari indicati nel
messaggio, o responsabili per la sua consegna alla persona, o se avete ricevuto
il messaggio per errore, siete pregati di non trascriverlo, copiarlo o inviarlo
ad alcuno. In tal caso vi invitiamo a cancellare il messaggio ed i suoi
allegati. Grazie.
CONFIDENTIALITY NOTICE Confidential information may be contained in this
message or in its attachments. If you are not the addressee indicated in this
message, or responsible for message delivering to that person, or if you have
received this message in error, you may not transcribe, copy or deliver this
message to anyone. In that case, you should delete this message and its
attachments. Thank you.
PDFSignedFirmaCerta.pdf
Description: PDFSignedFirmaCerta.pdf
------------------------------------------------------------------------------ Site24x7 APM Insight: Get Deep Visibility into Application Performance APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month Monitor end-to-end web transactions and take corrective actions now Troubleshoot faster and improve end-user experience. Signup Now! http://pubads.g.doubleclick.net/gampad/clk?id=267308311&iu=/4140
_______________________________________________ iText-questions mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/itext-questions iText(R) is a registered trademark of 1T3XT BVBA. Many questions posted to this list can (and will) be answered with a reference to the iText book: http://www.itextpdf.com/book/ Please check the keywords list before you ask for examples: http://itextpdf.com/themes/keywords.php
