Discussion:
[iText-questions] PdfSmartCopy cause signature corrupt
Eric Chow
2015-10-14 04:53:21 UTC
Permalink
Hello,

I use PdfSmartCopy to merge two PDF files.

One of the PDF file contains a Digital Signature.
After I used PdfSmartCopy to merge them, there is not any signature filed
in the side bar of Adobe reader.

If I click on the signature field in the pdf page, it shows the signature
data is corrupted.

Is there anything I miss to do? Please help!


The following is my code to merge two files:



OutputStream os = new FileOutputStream(out);
Document document = new Document();

PdfSmartCopy copy = new PdfSmartCopy(document, os);



document.open();

String[] files = { "pdf_has_signature.pdf", "another_pdf.pdf" };


PdfReader reader;
int n;

for (int i = 0; i < files.length; i++) {

reader = new PdfReader(files[i]);
// loop over the pages in that document
n = reader.getNumberOfPages();


for (int page = 1; page <= n; page++) {
copy.addPage(copy.getImportedPage(reader, page));
}
cop

copy.freeReader(reader);
reader.close();

}
mkl
2015-10-14 15:36:44 UTC
Permalink
Eric,
Post by Eric Chow
I use PdfSmartCopy to merge two PDF files.
One of the PDF file contains a Digital Signature.
After I used PdfSmartCopy to merge them, there is not any signature filed
in the side bar of Adobe reader.
If I click on the signature field in the pdf page, it shows the signature
data is corrupted.
Is there anything I miss to do?
Essentially you misunderstand the concept of digital signatures in general
and those integrated in PDFs in particular: They are not merely some pretty
images on some PDF page or signature side bar, they are backed by
cryptographical fingerprints which allow validators (e.g. Adobe Reader) to
check whether the signed material has been changed.

Thus, the only way to change a signed PDF without breaking the signature is
by means of an incremental update, and even then only a very few types of
changes are allowed, cf. this stackoverflow answer.
<http://stackoverflow.com/a/16711745/1729265>

In the context of iText this means you may only manipulate the document
using a PdfStamper in append mode, and even then only a few of its methods
may be used.

Using a PdfCopy variant in particular totally messes up the signature from a
merged document, and merging documents with digital signatures is a no-go
anyways.

Regards, Michael



--
View this message in context: http://itext.2136553.n4.nabble.com/PdfSmartCopy-cause-signature-corrupt-tp4660917p4660918.html
Sent from the iText mailing list archive at Nabble.com.

------------------------------------------------------------------------------
_______________________________________________
iText-questions mailing list
iText-***@lists.sourceforge.net
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
Loading...