Skip to main content
Participating Frequently
Feb 21, 2008 9:38 PM UTC
Question

Add Digital Signature Using C# and Acrobat SDK

Hi everybody!

Please, how can I digitally sign PDF documents using Acrobat Professional 8 API and C# language?
I know that I need use JavaScript APIs (IAC) but I can't find anything really helpful in the Acrobat SDK Documentation. Could anyone post a sample of how use javascript manipulation inside C# (Framework 2.0), or give me a direction?

Thank in advance!
This topic is closed to new replies. Start a new post to keep the conversation going.

63 replies

Participant
Jun 19, 2008 9:53 AM UTC
Hi Aandi Inston,

I posted a new topic.

Thanks a lot for your response.
Translate
Participant
Jun 19, 2008 9:47 AM UTC
Hi PDL/Fornachari,

I am using VB.Net and i have to create .PostScript file using Adobe javascript.

I am able to create .ps in abode using javascript.

Now I want to call that Javascript in my VB.Net code using JSO object.

I copied the javascript in C:\Program Files\Adobe\Acrobat 8.0\Acrobat\Javascripts folder.

VB.NET Code:-

Dim gApp As Acrobat.CAcroApp
Dim gPDDoc As Acrobat.CAcroPDDoc
Dim jso As Object

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

gApp = CreateObject("AcroExch.App")
gPDDoc = CreateObject("AcroExch.PDDoc")
jso = gPDDoc.GetJSObject

End Sub

Adobe Javasccript:-

function JSPDFTOPS(theDoc)
{
var pp = theDoc.getPrintParams();
pp.interactive = pp.constants.interactionLevel.silent;
var fv = pp.constants.flagValues;
pp.flags |= fv.setPageSize;
theDoc.print(pp);
}

Now please guide how can i call this javascript into my VB.Net code.

Thanks in Advance
Translate
Participating Frequently
Jun 19, 2008 9:48 AM UTC
>I am using VB.Net and i have to create .PostScript file using Adobe javascript.

Are you trying to add a digital signature? Are you using C#?
If not, I recommend you start a new topic, because adding to an
unrelated topic will be less helpful to you.

Good luck,

Aandi Inston
Translate
Participating Frequently
Mar 25, 2008 8:18 PM UTC
Ok, thank you!
I will search a little more.
Translate
Participant
Feb 16, 2010 8:40 PM UTC

Fornachari,

I am looking for a solution for a very similar problem - Signing a PDF with C# and Acrobat SDK using certificate stored in a USB Token.

Did you find a solution for this? Any help is really appreciated.

Thanks,

Paddy

Translate
Patrick_Leckey
Participating Frequently
Mar 25, 2008 8:09 PM UTC
Yes, that is because your certificate is not a PKCS#11 Library. That is stored on the smart card. You may have to discuss with the manufacturer how to access it.
Translate
Participating Frequently
Mar 25, 2008 7:50 PM UTC
Thank you PDL, but It isn't the problem.
I tried now this:

myEngine.login( {oParams:{cPassword: "MyPassword", cDIPath: oCerts[iSerial]}});

But did not work. But, if I pass a valid PFX path instead of oCerts[iSerial], this code works, like the other.
Translate
Patrick_Leckey
Participating Frequently
Mar 25, 2008 6:31 PM UTC
I just noticed something. When you're performing your login you are using an optional LoginParameters object.

myEngine.login( {oParams:{oEndUserSignCert: oCerts[iSerial] , cPassword: "MyPassword"}});

You are not specifying the cDIPath parameter which must point to your smart cards PKCS#11 library.
Translate
Participating Frequently
Mar 25, 2008 4:22 PM UTC
[object Certificate = SubjectDN: cn=Felipe Fornachari, email=MyEmail, o=MyCompany, ou=MycompanyUnit, c=MyCountry]

I just change my personal informations, but the output is like above.
This is the right output, is'nt it?
Translate
Patrick_Leckey
Participating Frequently
Mar 25, 2008 3:55 PM UTC
PFX is usually PKCS#12. Strange, you should have the added password field (that field is only processed in a SignatureInfo variable on public-key certificates). Perhaps since it's coming from MSCAPI it is not seeing it as a public-key certificate.

If you just console.println(oCerts[iSerial]) what does it output?
Translate
Participating Frequently
Mar 25, 2008 3:45 PM UTC
Hi PDL, thank you again.
I can't access the smart card directly, but, reading the documentation of the smart card, the format of the certificate is
PFX.
Any idea?
Translate
Patrick_Leckey
Participating Frequently
Mar 25, 2008 2:54 PM UTC
PKCS#11 (Cryptoki API) is just an abstract set of generic functions for (mostly) smart card certificates. In what format are your certificates on the smart card?
Translate