Skip to main content
Participating Frequently
February 21, 2008
Question

Add Digital Signature Using C# and Acrobat SDK

  • February 21, 2008
  • 56 replies
  • 47957 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

Patrick_Leckey
Participating Frequently
February 26, 2008
Assuming you meant "Object jso = acroAVDoc.GetJSObject()" then there are several problems...

You need to load a document into your AcroAVDoc object in order to get it's JSObject. The JSObject will be null if no document has been loaded (JSObject is the JavaScript Doc class, so if there is no Doc ...)

If your sdkAddSignature.js is being loaded by Acrobat as a folder-level javascript, you can call functions you declared within the sdkAddSignature.js file through the JSObject. You just can't use a null JSObject.
Participating Frequently
February 26, 2008
PDL, ok, lets go and thanks a lot the help:

I am working with C# (Framework 2.0) and I need to invoke a Javascript code (inside my C# app) that signs a pdf document.
There is a Javascript code, that came with the Acrobat SDK documentation, that signs a pdf. The name of this file is sdkAddSignature.js. If you have the Acrobat 8.0 SDK documentation, you can find this file in the folder \\Adobe Adobe SDK 8.1\Acrobat 8 SDK\Version2\JavaScriptSupport\Samples\OutsidePDF\AddSignature.
I put this JS file inside the Acrobat javascript default folder: c:\Program Files\Adobe\Acrobat 8.0\Acrobat\Javascripts

I am creating my JSObject like below:

AcroAVDoc acroAVDoc = new AcroAVDoc();
Object jso = acroDoc.GetJSObject();

And now, I don't know how invoke the sdkAddSignature.js! I can't use jso.<method name>(<parameters>); This not works, because I need to invoke MY javascript code, and not a existing method in the Acrobat.dll

Any ideas to invoke the javascript code?

Sorry my questions, but I really need this informations and I'm not finding in the Acrobat documentation! Thanks!!
Patrick_Leckey
Participating Frequently
February 26, 2008
Felipe -

I added a document-level JavaScript to a blank PDF (Toolbar Menu: Advanced > Document Processing > Document Javascripts). I named the function "showMyMessage" (with no parameters) and executed it through the JSObject by calling jso.showMyMessage() in my script. The script opened the document and executed the script successfully.

Perhaps if you post your code as to how you are acquiring the JSObject we may be able to help more. What you are trying to do clearly works so we need to figure out where the hiccup in your script is.
Participating Frequently
February 26, 2008
Yes Eugene. I did exactly what I needed using a component called iTextSharp, but here, in the company, they really want to use the Acrobat SDK, and I know that is possible to invoke a javascript code from C#.

Could anyone help me to invoke a javascript code in C#, using the Acrobat SDK?
Participating Frequently
February 25, 2008
Yeah PDL, you got the point.
I need to apply a digital signature in a PDF file. I need to do this inside my C# application, because the user will have other features besides signing.
I fond in the SDK documentation a sample of javascript code that digitally sign the document, and I read that I need to invoke a javascript code to digitally sign a pdf with C#, because there are no methods to sign just using the Acrobat.dll. I read that to invoke the javascript code I need to create a JSObject, am I right?

I just need to invoke a javascript code from C#, could you help me? Do you know how can I get this? Could you give a example??

Thank you all very much!
Participant
February 26, 2008
Hello!
You wrote on Mon, 25 Feb 2008 09:29:13 -0800:

FF> I just need to invoke a javascript code from C#, could you help me? Do
FF> you know how can I get this? Could you give a example??

Did you consider third-party components for signing PDF directly from C#?
There are several options available and they don't require Adobe SDK.

With best regards,
Eugene Mayevski
http://www.SecureBlackbox.com - the comprehensive component suite for
network security
Patrick_Leckey
Participating Frequently
February 25, 2008
Ah - you are trying to execute javascript functions you wrote yourself and not the ones exported by the JSObject?
Participating Frequently
February 25, 2008
It's not that you need to write JavaScript code (although you could if you wanted to) - it's that you can/should invoke the JS methods AS IF THEY WERE native C# methods via the JSObject.

Leonard
Participating Frequently
February 25, 2008
I'm sorry Leonard Rosenthol, I'm new with de Acrobat SDK. I think I understand wrong the IAC concept, I thought that I would invoke a javascript code from anywhere. So, I need to make the javascript code directly in my C# application, using the JSO, is it?
Participating Frequently
February 25, 2008
No need for JavaScript to go anywhere other than your C# application.

Leonard
Participating Frequently
February 25, 2008
Maybe, the correct way is this:

jso.GetType().InvokeMember(<method name>(<parameters>))

What do you think?

And other doubt, I know that there is a folder, in the Acrobat Professional directory, where I should put my javascript code, to invoke through my C# application, right?
I searched in the directory, but I didn't find where is the javascript folder. Please, could you tell the javascript folder name?

The "<method name>" would be the name of the javascript code, that is inside the javascript folder?