Do you own a Debenu Quick PDF Library version 7, 8, 9, 10, 11, 12, 13 or iSEDQuickPDF license? Upgrade to Debenu Quick PDF Library 14 today!
SaveToFile with signature |
Post Reply |
Author | |
John Chen
Beginner Joined: 26 Dec 14 Location: Taiwan Status: Offline Points: 9 |
Post Options
Thanks(0)
Posted: 21 Jan 15 at 3:31AM |
Used QP.LoadFromFile(L"xxx.pdf",L"") to open pdf file with signature. Then used QP.SaveToFile(L"yyy.pdf") to save to different pdf file. The signature become "Signature contains incorrect....". How can I save as a pdf file with signature to different pdf file?
|
|
mLipok
Senior Member Joined: 23 Apr 14 Location: Poland, Zabrze Status: Offline Points: 449 |
Post Options
Thanks(0)
|
If you change anything in any (not only PDF) signed file then signature always will show you similar message.
In another case, the signatures would be useless.
|
|
Here you can find description how to test my examples:
http://www.quickpdf.org/forum/forum_posts.asp?TID=2932&PID=12600&title=drawcapturedpagematrix-matrix-howto#12600 |
|
John Chen
Beginner Joined: 26 Dec 14 Location: Taiwan Status: Offline Points: 9 |
Post Options
Thanks(0)
|
I didn't change any thing, just LoadFromFile then SaveToFile. The signature shown "Error...". I used the Adobe reader to open same file, then "SaveAs" to other file, the signature seem fine.
|
|
mLipok
Senior Member Joined: 23 Apr 14 Location: Poland, Zabrze Status: Offline Points: 449 |
Post Options
Thanks(0)
|
When using Acrobat Reader, the option Save As, just make a copy of the same file (compare the contents in an editor HEX).
When you open a PDF document using library functions QP.LoadFromFile then using QP.SaveToFile, you do not create a copy of this document. You create a new (different) document (compare the contents in an editor HEX). Because the contents of the file is changed, the message "Signature contains incorrect ...." is clear and correct.
Edited by mLipok - 25 Jan 15 at 1:15PM |
|
Here you can find description how to test my examples:
http://www.quickpdf.org/forum/forum_posts.asp?TID=2932&PID=12600&title=drawcapturedpagematrix-matrix-howto#12600 |
|
John Chen
Beginner Joined: 26 Dec 14 Location: Taiwan Status: Offline Points: 9 |
Post Options
Thanks(0)
|
Thank you,mLipok. The B.pdf file with signature1, then add new signature2 and save to c.pdf (1). nSignProcessID =QP.NewSignProcessFromFile(L"C:\\TEST\\B.pdf",L""); ............................ QP.EndSignProcessToFile(nSignProcessID,L"c:\\test\\C.pdf"); The signature1 and signature2 shown correct. (2). QP.LoadFromFile(L"c:\\TEST\\B.pdf",L""); std::string FileString(QP.SaveToString());
// save to string nSignProcessID =
QP.NewSignProcessFromString(FileString,L""); QP.SetSignProcessPFXFromFile(nSignProcessID,swPFXFile,swPassword); ................... QP.EndSignProcessToFile(nSignProcessID,L"c:\\test\\C.pdf"); (3). QP.LoadFromFile(L"c:\\TEST\\B.pdf",L""); QP.SaveToFile(L"c:\\TEST\\tmp.pdf"); nSignProcessID = QP.NewSignProcessFromFile(L"C:\\TEST\\tmp.pdf",L""); QP.SetSignProcessPFXFromFile(nSignProcessID,swPFXFile,swPassword); ........................ QP.EndSignProcessToFile(nSignProcessID,L"c:\\test\\C.pdf"); The signature1 shown incorrect, the signature2 shown correct in 2,3. In (2),(3), save to file or string first, then signature process to save to c.pdf, the signature become incorrect. In (1), use signature process directly, the signature are correct. They are different in SaveToFile/SaveToString. |
|
mLipok
Senior Member Joined: 23 Apr 14 Location: Poland, Zabrze Status: Offline Points: 449 |
Post Options
Thanks(0)
|
Honestly I have never used the option of signing PDF files in this library.
My previous answers were general in nature. As for your last question, unfortunately I am not able to answer now.
|
|
Here you can find description how to test my examples:
http://www.quickpdf.org/forum/forum_posts.asp?TID=2932&PID=12600&title=drawcapturedpagematrix-matrix-howto#12600 |
|
mLipok
Senior Member Joined: 23 Apr 14 Location: Poland, Zabrze Status: Offline Points: 449 |
Post Options
Thanks(0)
|
btw.
I re read Debenu Quick PDF Library 11 Developer Guide.pdf and here is explanation Processing digitally signed PDF files Any changes that you make to a PDF after it has been digitally signed will invalidate the digital signature. PDF files that contain digital signatures must be incrementally updated -- meaning that the contents of the PDF are updated without rewriting the entire file by way of appending changes to the end of the file. If digitally signed PDF files are not updated this way then the digital signature will not only be invalidated, but it will be completely broken too. When using Debenu Quick PDF Library it’s important to note that the combination of LoadFromFile and SaveToFile does not incrementally update the file. Instead it completely rewrites the contents of the PDF and breaks the digital signature. If you’re working with a PDF that has a digital signature and you do not want to break or remove the digital signature, then you should not use the SaveToFile function. If you need to modify a PDF that has been digitally signed then you should use the DAOpenFile and DAAppendFile functions as the DAAppend function does incrementally update PDF files, which means that the digital signature will be invalidated, but not broken. |
|
Here you can find description how to test my examples:
http://www.quickpdf.org/forum/forum_posts.asp?TID=2932&PID=12600&title=drawcapturedpagematrix-matrix-howto#12600 |
|
Rowan
Moderator Group Joined: 10 Jan 09 Status: Offline Points: 398 |
Post Options
Thanks(0)
|
I should add that the AppendToFile function has been added to the regular functions as well, so you can use it there too. I will update this in the developer guide.
As for the LoadFromFile - > SaveToFile example, this re-writes the file. I presume when you do something similar in Adobe Reader / Acrobat it sees that it contains a digital signature and makes no changes to the document, just saves an identical copy of the file that was loaded. We're working at a lower level so the developer has to implement checks like that in their applications, in the same way that the developers of Adobe products do. With regards to your other question, you need to use the AppendToFile function. That will do an incremental update. This will still invalidate the previous signature that was added to the document -- as the document has changed -- but it should not *break* the previous signature, which is the crucial point. |
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |
Copyright © 2017 Debenu. Debenu Quick PDF Library is a PDF SDK. All rights reserved. About — Contact — Blog — Support — Online Store