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!

Debenu Quick PDF Library - PDF SDK Community Forum Homepage
Forum Home Forum Home > For Users of the Library > I need help - I can help
  New Posts New Posts RSS Feed - SaveToFile with signature
  FAQ FAQ  Forum Search   Register Register  Login Login

SaveToFile with signature

 Post Reply Post Reply
Author
Message
John Chen View Drop Down
Beginner
Beginner


Joined: 26 Dec 14
Location: Taiwan
Status: Offline
Points: 9
Post Options Post Options   Thanks (0) Thanks(0)   Quote John Chen Quote  Post ReplyReply Direct Link To This Post Topic: SaveToFile with signature
    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? 
Back to Top
mLipok View Drop Down
Senior Member
Senior Member
Avatar

Joined: 23 Apr 14
Location: Poland, Zabrze
Status: Offline
Points: 449
Post Options Post Options   Thanks (0) Thanks(0)   Quote mLipok Quote  Post ReplyReply Direct Link To This Post Posted: 23 Jan 15 at 4:05AM
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
Back to Top
John Chen View Drop Down
Beginner
Beginner


Joined: 26 Dec 14
Location: Taiwan
Status: Offline
Points: 9
Post Options Post Options   Thanks (0) Thanks(0)   Quote John Chen Quote  Post ReplyReply Direct Link To This Post Posted: 23 Jan 15 at 6:59AM
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. 
Back to Top
mLipok View Drop Down
Senior Member
Senior Member
Avatar

Joined: 23 Apr 14
Location: Poland, Zabrze
Status: Offline
Points: 449
Post Options Post Options   Thanks (0) Thanks(0)   Quote mLipok Quote  Post ReplyReply Direct Link To This Post Posted: 25 Jan 15 at 1:14PM
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
Back to Top
John Chen View Drop Down
Beginner
Beginner


Joined: 26 Dec 14
Location: Taiwan
Status: Offline
Points: 9
Post Options Post Options   Thanks (0) Thanks(0)   Quote John Chen Quote  Post ReplyReply Direct Link To This Post Posted: 26 Jan 15 at 10:05AM
Thank you,mLipok.

I have a new question about signature. I have 3 way to try for signature.
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.




Back to Top
mLipok View Drop Down
Senior Member
Senior Member
Avatar

Joined: 23 Apr 14
Location: Poland, Zabrze
Status: Offline
Points: 449
Post Options Post Options   Thanks (0) Thanks(0)   Quote mLipok Quote  Post ReplyReply Direct Link To This Post Posted: 26 Jan 15 at 3:53PM
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
Back to Top
mLipok View Drop Down
Senior Member
Senior Member
Avatar

Joined: 23 Apr 14
Location: Poland, Zabrze
Status: Offline
Points: 449
Post Options Post Options   Thanks (0) Thanks(0)   Quote mLipok Quote  Post ReplyReply Direct Link To This Post Posted: 26 Mar 15 at 8:47PM
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
Back to Top
Rowan View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 10 Jan 09
Status: Offline
Points: 398
Post Options Post Options   Thanks (0) Thanks(0)   Quote Rowan Quote  Post ReplyReply Direct Link To This Post Posted: 29 Mar 15 at 1:05PM
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.



Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 11.01
Copyright ©2001-2014 Web Wiz Ltd.

Copyright © 2017 Debenu. Debenu Quick PDF Library is a PDF SDK. All rights reserved. AboutContactBlogSupportOnline Store