Copy link to clipboard
Copied
Hi all,
I need to extract signatures information from PDF files in VBA (Mainly the signatory name and the signature date. The PDF files have several signatures inside them).
So I have got some questions :
- Is there a example somewhere to do such a thing?
- Will I need Acrobat Pro for that purpose? This is an important point as the code is supposed to be ran on machines where ONLY Acrobat Reader is installed.
- If the above is impossible, do you know about a command line utility that would do the thing (and that I could run from my VB code)
Thank you for your help
Emphyrio
1 Correct answer
As was already mentioned, you will need Adobe Acrobat Standard or Pro to use the VB/JS bridge. If you want to make this work with just the free Reader, you are limited to what you can do within the JavaScript environment. This basically means that you have to open the file in Reader, and then use e.g. a menu item to trigger the functionality to get the information about the signatures in your file. This information can then e.g. be displayed on a dialog, and you would be able to copy & paste fro
...Copy link to clipboard
Copied
You can do it from JavaScript inside of either Acrobat or Reader – but only Acrobat supports a VB->JS bridge.
Copy link to clipboard
Copied
Take a look at this link http://www.khk.net/wordpress/2010/09/23/reading-pdf-form-fields-with-vba/
It may lead you in the right direction
Copy link to clipboard
Copied
As was already mentioned, you will need Adobe Acrobat Standard or Pro to use the VB/JS bridge. If you want to make this work with just the free Reader, you are limited to what you can do within the JavaScript environment. This basically means that you have to open the file in Reader, and then use e.g. a menu item to trigger the functionality to get the information about the signatures in your file. This information can then e.g. be displayed on a dialog, and you would be able to copy & paste from that dialog (this means no VBA integration at all).
You can of course use either Adobe's PDF Library (licensed via Datalogics), or other 3rd party PDF frameworks/libraries. This being a site run by Adobe, you may understand that we cannot give you any advice in regards to 3rd party solutions that compete with Adobe's own solution.
Copy link to clipboard
Copied
Good afternoon,
I apologize in advance if related questions are preferred posed using a new thread but this particular thread seems pretty current and very relevant to what it is i'm currently stumped on. I recently starting using the VB/JS bridge and the JSO object to extract signatureinfo from PDF documents as they gather signatures. The problem i'm having is that the signatureinfo.date is interpreted by VBA in what I believe is a different regional format so it comes through VBA incorrectly. For example, i signed a document this morning and tested my script out and signatureinfo.date returned 11/02/2016 rather than 11/22/2016. I double checked several different signatures and I found similar results (month/day/year in different order that confuses VBA perhaps?). If I open the PDF and click on the signature itself, PDF has the correct date/timestamp. I was looking for a way to grab a text version and then do some string manipulations as a work around but i can't seem to get the VBA side of the house to give me an accurate reference to the date from which to work with. Has anyone encountered similar situations and is there a known workaround? A short background, I create a PDF from excel that then gets posted in a shared location for others to approve with a digital signature. What my script does is open each PDF, scan all signatures and note those signature back into an access database. The signatureinfo.date doesn't bug out, it just doesnt return the accurate date and the research i've done points to an issue with regional interpretation from what i can tell.
Appreciate any insight and recommendations!
Tyson
Copy link to clipboard
Copied
If you do the work entirely in JS – do you get the right result? That may help determine if the problem is date handling across the bridge or something else.
Copy link to clipboard
Copied
i just stumbled upon a different adobe post (how i didn't find this post in the last couple of days while searching is beyond me - must not have triggered the Google search engine). I'm going to give the work around referenced at the bottom of this thread a try, and if it works properly and solves my date issues, i'll respond back to confirm. Thanks for the quick replay Irosenth.
Copy link to clipboard
Copied
Hello everyone,
I had to incorporate the answer from the SignatureInfo.Date Displays wrong Day answer from the post above and do a few tweaks but below is the code that is working successfully for me now. It will debug.print in the VB Editor both versions of the date to illustrate some weird interpretation of the jso.getField(x).SignatureInfo.Date.
Sub test_sig()
Dim oApp As Acrobat.AcroApp
Dim oAVDoc As Acrobat.CAcroAVDoc
Dim oPDDoc As Acrobat.CAcroPDDoc
Dim formApp As AFORMAUTLib.AFormApp 'added reference
Dim acroForm As AFORMAUTLib.Fields 'added reference
Dim jso As Object
Dim file_path As String, f As String, js As String
Dim i As Integer, ncol_0 As Integer, ncol_1 As Integer
Dim wf As WorksheetFunction
Dim real_date As Variant
file_path = "your path here\your file name here.pdf"
Set oApp = CreateObject("AcroExch.App")
Set oAVDoc = CreateObject("AcroExch.AVDoc")
oAVDoc.Open file_path, ""
Set oPDDoc = oAVDoc.GetPDDoc
Set jso = oPDDoc.GetJSObject
Set formApp = CreateObject("AFormAut.App")
Set acroForm = formApp.Fields
Set wf = WorksheetFunction
For i = 0 To jso.numfields - 1
f = jso.getnthfieldname(i)
If jso.getField(f).Type = "signature" Then
Debug.Print jso.getField(f).SignatureInfo.Name
Debug.Print "VBA Date is returned as " & jso.getField(f).SignatureInfo.Date
js = "var Info = this.getField('" & f & "').signatureInfo(); event.value = " & Chr(34) & " " & Chr(34) & " + Info.date;"
real_date = wf.Trim(wf.Clean(acroForm.ExecuteThisJavascript(js)))
nchar_0 = InStr(1, real_date, " ") + 1
nchar_1 = InStr(1, real_date, "GMT") - 1
real_date = Mid(real_date, nchar_0, nchar_1 - nchar_0)
Debug.Print "JS Date is returned as " & (CDate(real_date))
End If
Next i
End Sub

