Hi, I've been using your PDF printer for some time now from C++, and it works great, but I can't figure out how to digitally sign a PDF from C++. There doesn't appear to be any documentatation for the non-activeX version of the DigitalSignature function. I found this in another thread on this board:
5) You can set Digital signature using the ActiveX interface of CDintf or using the following function of the DLL:
int WINAPI DocDigitalSignatureA(EXTDOCHANDLE edhDocument, LPCSTR SignedBy, LPCSTR Reason, LPCSTR ImageFile, LPCSTR Location, long PageNumber, long HorzPos, long VertPos, long Width, long Height, long Flags)
I really want to use this function, but it's not documented anywhere that I can find. What is an EXTDOCHANDLE? If you could direct me to documentation, or better yet an example use of this function, I would really appreciate it.
Please check that the signature name you are using is a valid signature on your system. Please note that C# is case sensitive.
I don't have a list of the returned values of DocDigitalSignatureA because this is a new function and it is not documented yet. I will try to get this list and post it here.
As mentioned by Joanna, the situation you have encountered typically occurs when the digital signatures function is unable to successfully apply the digital signature to the document. From the error you are receiving it looks like you have not specify a valid digital signature value in the DocDigitalSignatureA() function.
Our Digital Signatures option uses the Microsoft signature handler (PPKMS digital signatures types) and the resulting signed documents are viewable in Adobe Reader (windows) versions 4.0 and higher.
Also, the digital signature option of the PDF Converter functions with digital certificates which are stored in the "My" or "Personal" store
I will add here the return values of DocDigitalSignatureA():
-0 in case of success.
-100 in case the license does not cover digital signatures.
-1001 in case of lack of resources
-1099 in case signing failed, most probably it is either
1- The page number is incorrect
2- The certificate cannot be used for document signing
Thanks, that helps. I was passing 0 for the page and I guess that was why it was failing. That seems odd though, since I wasn't specifying the associated image flag (8).
When I gave it a page number (1) it then succeeded, but adobe reader still didn't pop up the message to say the document was signed.
I then added an image, and now when I open it up in reader, I can click on the image and it will tell me the document is signed.
So now my question: Why doesn't reader automatically pop up the dialog to say the document is signed? (It does for the other signed PDF's I have) Also, must I give it an image, or is that optional? As it stands, if I don't give an image, I can't tell that it's signed it reader.
Also, is there a way to enumerate the available certificates on a computer? Or must I have the user type in the cert's name?
Oh, I'm using a free certificate from thawte for my testing, if that makes any difference.
I tried to open two files having a signature one with picture and the other without picture, in both cases i didn't get any pop up from Adobe Reader and in both cases the files appear to be signed because the signature is there and there is a small sign on the horizontal bar stating that the document is signed.
For enumerating the signatures, i am not sure i really get what you mean.
If you are using the End User version of our Converter or Creator, you can, as End User, click on a browse button in our interface that will open a dialog box from which you can select the signature.
You may implement the same thing in your application but i am not sure how to do that, you need to check the Windows APIs that lists the signatures available on the system.