To achieve above goal, Adobe Acrobat professional and Adobe SDK is required.
Before writing c# code we need to following configuration setting
copy sdkAddSignature.js from Adobe\Acrobat 8 SDK\Version2\JavaScriptSupport\samples\outsidepdf\addsignature to adobeprofession javascript folder
copy DrTest.pft from Adobe\Acrobat 8 SDK\Version2\JavaScriptSupport\samples\outsidepdf\addsignature to C:\ (anywhere you like to)
Add reference of Interop.Acrobat.dll from Acrobat SDK
we can modify the location of signature on pdf or even hide it modifying the AddSignatureField function in sdkAddSignature.js.
Here is the final c# code which will add signature on pdf
Type AcrobatCAcroAppType;
AcrobatCAcroAppType = Type.GetTypeFromProgID("AcroExch.app");
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("c:\\s.pdf"))
{
jso = gpddoc.GetJSObject();
object[] param = new object[1];
param[0] = "testpassword";
object con = jso.GetType().InvokeMember("SetUserPassword",
BindingFlags.InvokeMethod , null, jso, param);
param[0] = "C:\\DrTest.pfx";
con = jso.GetType().InvokeMember("SetUserDigitalIDPath",
BindingFlags.InvokeMethod , null, jso, param);
param[0] = jso;
con = jso.GetType().InvokeMember("AddSignature",
BindingFlags.InvokeMethod , null, jso, param);
Happy Coding
:)
3 comments:
Hi! I'm using your code. But object con always return NULL. Can you help me why?
Getting the same problem. I used the given code but object con is returning the NULL. Am i missing something ? Please help me..
Hi what your sample code into C# for digital sign into PDF using adobe acrobate
please help me.
or replay on rneeraj01@gmail.com
Post a Comment