Planet PDF Forum Archive

Planet PDF ForumWowsers! This is page is old, head to the LIVE Planet PDF Forum. It features more than 10 conferences, covering everything from beginner to in-depth developer and pre-press discussions. If you wish to continue... one & two archive covers 1999-2011 (160,000 pages).

New Forum | Previous | Next | (P-PDF) Developers

Topic: Programmatically signing a PDF document
Conf: (P-PDF) Developers, Msg: 142982
From: hez0s0
Date: 11/21/2005 10:39 PM

i'm trying to develop a VB application to add digital signature to a PDF Document.
It's going to run on a desktop environment, with full Acrobat 7.0 installed, and i thought
a good choice would be using JSObject to access Javascript security funcions directly
from VB. I managed to add correctly a signature to the document, after reading sample code
(most from this forum), by accessing a password-protected pfx file. Code looks like this:

Set acrobatApplication = CreateObject("AcroExch.App")
Set AVDoc = CreateObject("AcroExch.AVDoc")
Set gPDDoc = CreateObject("AcroExch.PDDoc")

If gPDDoc.Open("c:\adobe.pdf") Then
Set jso = gPDDoc.GetJSObject
Set oAdd = jso.addField("FirmaField1", "signature", 0, Array(20, 100, 100, 20))
Set oSign = jso.getField("FirmaField1")
Set ppklite ="Adobe.PPKLite", True)

ppklite.login "1111", "c:\certificate_file.pfx"
oSign.signatureSign ppklite
end if

However, i actually need to access a certificate in Windows system storage, not a pfx file.
I can read Windows storage and select the certificate i'm searching, this way:

certs = ppklite.digitalIDs.certs
For Each cCert In certs
If (cCert.serialNumber = strWantedSerial) Then
Set cSelectedCert = cCert
End If

Now, it's supposed i can login and sign this way:
ppklite.login cSelectedCert
oSign.signatureSign ppklite

But it doesn't work. Either if the certificate is
in a smartcard, or just in Windows storage, it throws this error:

"GeneralError: Operation failed.
[ Creation of this signature could not be completed. ] ->
[ You have not selected a valid Digital ID. Please try again. ]"

Any idea to solve this problem?

Thank you in advance,

Regards, Gustavo.

PDF In-Depth Free Product Trials Ubiquitous PDF

Debenu Aerialist

The ultimate plug-in for Adobe Acrobat. Advanced splitting, merging, stamping, bookmarking, and link...

Download free demo

Debenu PDF Tools Pro

It's simple to use and will let you preview and edit PDF files, it's a Windows application that makes...

Download free demo

Five visions of a PDF Day

In the world of PDFs or as we like to say Planet (of) PDF, a year isn't a real PDF year without an intense few days of industry knowledge sharing.

May 15, 2018
Platinum Sponsor

Search Planet PDF
more searching options...
Planet PDF Newsletter
Most Popular Articles
Featured Product

Debenu PDF Aerialist

The ultimate plug-in for Adobe Acrobat. Advanced splitting, merging, stamping, bookmarking, and link control. Take Acrobat to the next level.


Adding a PDF Stamp Comment

OK, so you want to stamp your document. Maybe you need to give reviewers some advice about the document's status or sensitivity. This tip from author Ted Padova demonstrates how to add stamps with the Stamp Tool along with related comments.