PdfSmartCopy cause signature corrupt

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

PdfSmartCopy cause signature corrupt

Eric Chow
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();

}

------------------------------------------------------------------------------

_______________________________________________
iText-questions mailing list
[hidden email]
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
mkl
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: PdfSmartCopy cause signature corrupt

mkl
Eric,

Eric Chow wrote
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.

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
Loading...