Add Digital Signature to a PDF programmatically using Adobe SDK and Microsoft .NET

  • Post author:
  • Post category:Blog
  • Post comments:0 Comments
  • Reading time:2 mins read


– Adobe Professional Installed

– Adobe SDK downloaded

– Microsoft Visual Studio

– Valid Certificate file (.pfx). It means the .pfx file not yet expired.

Setup environment:

– Copy sdkAddSignature.js from SDK to Acrobat\Javascripts folder

– Optional: Create Your Own Test Certificate

Code C#

Type AcrobatCAcroAppType;
            AcrobatCAcroAppType = Type.GetTypeFromProgID("");
            Acrobat.CAcroApp gapp = (Acrobat.CAcroApp)Activator.CreateInstance(AcrobatCAcroAppType);
            Type AcrobatPDDocType;
            AcrobatPDDocType = Type.GetTypeFromProgID("AcroExch.PDDoc");
            Acrobat.CAcroPDDoc gpddoc = (Acrobat.CAcroPDDoc)Activator.CreateInstance(AcrobatPDDocType);
            object jso;
            if (gpddoc.Open("d:\\temp\\s.pdf"))
                jso = gpddoc.GetJSObject();
                object[] param = new object[1];
                param[0] = "c:\\CATest.pfx";
                object con = jso.GetType().InvokeMember("SetUserDigitalIDPath",
                BindingFlags.InvokeMethod, null, jso, param);
                param[0] = "testpassword";
                con = jso.GetType().InvokeMember("SetUserPassword",
                BindingFlags.InvokeMethod, null, jso, param);                    
                param[0] = jso;
                con = jso.GetType().InvokeMember("AddSignature",
                BindingFlags.InvokeMethod, null, jso, param);            

Code VB:

Dim gapp As Acrobat.CAcroApp
    Dim gpddoc As Acrobat.CAcroPDDoc
    Dim jso As Object
    gapp = CreateObject("")
    gpddoc = CreateObject("acroexch.pddoc")
    If gpddoc.Open("d:\temp\s.pdf") Then
      jso = gpddoc.GetJSObject()
    End If

Hope this help!

This Post Has 0 Comments

  1. Women Fashion

    Excellent post. I was checking constantly this weblog and I am impressed!
    Extremely helpful information specifically the last section 🙂 I take care of such info a lot.
    I used to be looking for this particular information for a very long time.
    Thank you and good luck.

  2. Jeremy Garfield

    Nice blog post , my friend last month happened across to modify pdf ! It’s notably straightforward to try out and it’s good – I saw on the website they have a free trial now

  3. Sumit

    I cannot find sdkAddSignature.js file. and thus getting error at
    object con = jso.GetType().InvokeMember(“SetUserDigitalIDPath”,
    BindingFlags.InvokeMethod, null, jso, param);
    Could you please help in this.

Leave a Reply