Skip to main content
Participating Frequently
February 21, 2008
Question

Add Digital Signature Using C# and Acrobat SDK

  • February 21, 2008
  • 56 replies
  • 47925 views
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 has been closed for replies.

56 replies

New Participant
June 19, 2008
Hi Aandi Inston,

I posted a new topic.

Thanks a lot for your response.
New Participant
June 19, 2008
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
Participating Frequently
June 19, 2008
>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
Participating Frequently
March 25, 2008
Ok, thank you!
I will search a little more.
New Participant
February 16, 2010

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

Patrick_Leckey
Participating Frequently
March 25, 2008
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.
Participating Frequently
March 25, 2008
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.
Patrick_Leckey
Participating Frequently
March 25, 2008
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.
Participating Frequently
March 25, 2008
[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?
Patrick_Leckey
Participating Frequently
March 25, 2008
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?
Participating Frequently
March 25, 2008
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?
Patrick_Leckey
Participating Frequently
March 25, 2008
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?