You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@pdfbox.apache.org by Jonathan Barbero <jo...@gmail.com> on 2017/02/09 19:10:08 UTC

Sign PDF to file, read it and save it again corrupts file

Hi,

 I sign a PDF to a file with *CreateSignature.java* , then I read the file
and save it again.
The final file has the signature corrupted by *Adobe Reader* program.

I attached the original, the signed PDF and the same file read and wrote
again.
Also a Java project with a test case to create the files in "test_data"
folder.

https://drive.google.com/file/d/0B_x5-ZgUNfwXc2VydGJkRkVJdFE/view?usp=sharing

Regards

Re: Sign PDF to file, read it and save it again corrupts file

Posted by Tilman Hausherr <TH...@t-online.de>.
Am 09.02.2017 um 20:10 schrieb Jonathan Barbero:
> Hi,
>
>  I sign a PDF to a file with *CreateSignature.java* , then I read the 
> file and save it again.
> The final file has the signature corrupted by *Adobe Reader* program.


Yes, of course. The normal save creates a new PDF, where all elements 
are newly ordered. Thus the signature is no longer valid.

If you want to make changes to a signed file (which is not really a good 
idea, the point of a signature is to show that it hasn't been changed), 
then you'd need to use saveIncremental. Which doesn't work on signed 
files, see PDFBOX-45, the last few entries.

Tilman


>
> I attached the original, the signed PDF and the same file read and 
> wrote again.
> Also a Java project with a test case to create the files in 
> "test_data" folder.
>
> https://drive.google.com/file/d/0B_x5-ZgUNfwXc2VydGJkRkVJdFE/view?usp=sharing
>
> Regards
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
> For additional commands, e-mail: users-help@pdfbox.apache.org