PDF file loaded and saved seems to be modified

Discussions about PDF management.
Post Reply
nenea
Posts: 5
Joined: Mon Jan 02, 2017 12:46 pm

PDF file loaded and saved seems to be modified

Post by nenea » Thu Dec 27, 2018 7:15 pm

Hi all,
I noticed that simply opening and saving a PDF file results in a modified file.

Example:
In filePath there is a signed PDF. Opening with Acrobat Reader validate the signature.

Then
GdPicturePDF _oGdPicturePDF = new GdPicturePDF();
_oGdPicturePDF.LoadFromFile(filePath, false);

_oGdPicturePDF.SaveToFile(newPath, false, true);


The saved file seems to be changed and the signature is not verified by Acrobat Reader.
I tried with linearize parameter true or false.

Am I doing something wrong?

Thank you very much
Nazareno

nenea
Posts: 5
Joined: Mon Jan 02, 2017 12:46 pm

Re: PDF file loaded and saved seems to be modified

Post by nenea » Fri Dec 28, 2018 11:38 am

Solved by myself.

Using SaveToFileInc did the work.

Matus
Posts: 4
Joined: Tue Jan 15, 2019 1:00 pm

Re: PDF file loaded and saved seems to be modified

Post by Matus » Wed Jan 16, 2019 4:58 pm

Hi,

This is correct behavior. GdPicture needs to parse the document upon loading it. In some cases in order to open the file we need to repair the files. Because of that saving the file will automatically reconstruct the PDF file. Digital signatures make sure there have not been any modifications in the file. Even single different byte will lead to invalid signature because the document hash will be different.

You have correctly used the SaveToFileInc. This method keeps the document data unchanged and any modifications are appended at the end of the file. This is a feature of PDF format. Without any modification the document and file data will be unchanged and the Digital Signature will be valid. In case there are modifications the file will hold separate document versions and the Digital Signature will be able to verify the version that was signed.
Best Regards,

Matus
GdPicture Dev Team

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 0 guests