sdkAddSIgnature.js called from VB app works only when Acrobat is running
Environment:
- Visual Studio 2015 Community,
- Adobe Acrobat Installed,
- Acrobat SDK downloaded and sdkAddSIgnature.js script copied to Adobe\Javascripts (visible at Edit menu -> Acrobat SDK JavaScript in Acrobat)
I have this situation:
- standard sdkAddSIgnature.js script copied from SDK
- simple code of VB.Net app:
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim gapp As Acrobat.CAcroApp
Dim gpddoc As Acrobat.CAcroPDDoc
Dim jso As Object
gapp = CreateObject("acroexch.app")
gpddoc = CreateObject("acroexch.pddoc")
Dim args() As String = Environment.GetCommandLineArgs()
If gpddoc.Open("c:\Temp\report.pdf") Then
jso = gpddoc.GetJSObject()
jso.SetUserDigitalIDPath("/C/Temp/cert.pfx")
jso.SetUserPassword("***")
jso.AddSignature(jso)
gpddoc.Save(0, "c:\Temp\report.pdf")
gpddoc.Close()
Me.Close()
End If
End Sub
End Class
After hours of misery trying to get sdkAddSIgnature.js working with VB.Net app I came to conclusion, that it works only when I have Acrobat running!
When Acrobat is closed my app does not sign PDF file, but only creates empty field for signing and that's it. There is no content in that field and when I click on it - tool window for signing document appears ob screen.
Situation changes when I run Acrobat - then signing PDF files with this app works OK.
As I read Acrobat DC SDK documentation ...
To obtain a security handler (the oSig parameter), invoke the security object getHandler method. The method, which returns a security handler object, takes the following parameters:
cName — The name of the security handler (contained in the security object’s handlers property)
bUIEngine — If true, the method returns the existing engine associated with the Acrobat user interface; if false, the default, it returns a new engine.
so script line:
var myEngine = security.getHandler(DigSigHandlerName);
(DigSigHandlerName being "Adobe.PPKLite") means, that new engine should be returned.
In my case, it appears like it VB app works good only when there is Acrobat running, hence -> when there is existing engine.
One thing left to say - Acrobat javascript debugging showed GeneralError ...
Please let me know how can I resolve that problem, to run VB app with stable result (signed PDF in this case) without Acrobat running all the time.