Print Page | Close Window

Digital Signature

Printed From: Debenu Quick PDF Library - PDF SDK Community Forum
Category: For Users of the Library
Forum Name: Sample Code
Forum Description: Share Debenu Quick PDF Library sample code with other forum members
URL: http://www.quickpdf.org/forum/forum_posts.asp?TID=3880
Printed Date: 22 Nov 24 at 12:54PM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: Digital Signature
Posted By: DigitalSignature
Subject: Digital Signature
Date Posted: 20 Jan 21 at 8:40AM
Hi, my application is in C/C++ for Windows platform & I want to use Quick PDF library to generate multi-lingual PDFs that are digitally signed using one of the certificates on system.

I'm unable to get any documentation on how would one use Quick PDF library to digitally sign a PDF using a certificate from store. All I've got until now is SetSignProcessCertFromStore method from the documents, but there is no sample code on how do I go about using it.

Any documentation or samples or guide on this would be really helpful.



Replies:
Posted By: tfrost
Date Posted: 20 Jan 21 at 1:34PM
I have not used a certificate from the Windows store, but I have used a certificate from a PFX file.

Basically you start a Sign Process with qp.NewSignProcessFromX, where X is 'file' or 'stream' or 'string' containing the PDF. This function returns a sign process ID which is required in all subsequent signing calls.

Then if you want a picture stamp, you may need to use SetSignProcessField, SetSignProcessFieldBounds, SetSignProcessFieldImageFromFile, and then you may need QP.SetNeedAppearances(0). 

Next, SetSignProcessSubFilter and SetSignProcessInfo if you need them.

Finally I use SetSignProcessPFXFromFile to load the certificate, but you would replace this with SetSignProcessCertFromStore. To save the signed PDF you call EndSignProcessToFile(id, outputpdffile) and qp.GetSignProcessResult. 

Make sure that you use a certificate which supports PDF-signing. Not all do. And it is essential to check, report and fix any error returns from the above functions, before continuing to the next one.

It does all work, but there is a lot to get right.  Persevere!


Posted By: DigitalSignature
Date Posted: 21 Jan 21 at 4:21AM
@tfrost That was really helpful, thank you. Will try this out and get back if I run into any issue.


Posted By: DigitalSignature
Date Posted: 28 Jan 21 at 1:21PM
@tfrost It worked! Thanks a lot.

For others who would have a similar requirement to sign PDF using windows store certificate the process is as follows :

1) Start a signing intent with NewSignProcessFromXXX & use SignProcessID returned by this method on all API calls below
2) Get SHA1 hash of the certificate and call SetSignProcessCertFromStore
3) Specify signature field on PDF using SetSignProcessField, if you don't have one, it'll create it for you
4) Call EndSignProcessToXXX to sign PDF
5) GetSignProcessResult can be used to verify if PDF was signed successfully


Posted By: mLipok
Date Posted: 23 Feb 21 at 11:36PM
maybe here:
https://developers.foxitsoftware.com/kb/article/advanced-options-signing-pdf-files/

btw.
Somebody can provide how to modify this example to use CryptCards ?



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



Print Page | Close Window

Forum Software by Web Wiz Forums® version 11.01 - http://www.webwizforums.com
Copyright ©2001-2014 Web Wiz Ltd. - http://www.webwiz.co.uk