How can verify digital signature in pdf file

How can verify digital signature in pdf file?

1 Like

Hi @nutan, you can very likely do it with Acrobat or Reader. Here’s how I open Acrobat (modify your path to suit.

You will need an appmask.
Imgur

I modified the selector for “Signatures”. It is now

window[class="#32770"][name="Preferences"] > pane[class="GroupBox"] > tree[class="SysTreeView32"][name="Categories:"] > [name="Signatures"]

Added was ’ > [name=“Signatures”]’, a control for which UiSpy did not correctly capture the selector. I used AutoIt simplespy script by junkew to help with UiAutomation selectors. It is a good tool.

With UiAutomation the elements you click on don’t always have to be visible. The code below has commented-out clicks of the ‘Down’ button to make the ‘Signatures’ control visible - this turned out not to be necessary, but I have left it in the code for troubleshooting.

import "C:\Users\you\Robin\Acrobat.appmask"

System.RunApplication                   ApplicationPath:  'C:\Program Files (x86)\Adobe\Acrobat 11.0\Acrobat\Acrobat.exe' \
                                        CommandLineArguments:'' \
                                        WorkingDirectory:'' \
                                        WindowStyle:System.ProcessWindowStyle.Normal \
                                        ProcessId=> ProcessId
                                        # Run application
UiAutomation.Windows.GetForegroundWindow        \
                                        WindowTitle=> WindowTitle \
                                        WindowInstance=> AcrobatInstance
                                        # For safety's sake, get the foreground window
                                        
MouseAndKeyboard.SendKeys TextToSend:  '{Alt}f' DelayBetweenKeystrokes:10

MouseAndKeyboard.SendKeys TextToSend:  '{Right}' DelayBetweenKeystrokes:10

MouseAndKeyboard.SendKeys TextToSend:  'n' DelayBetweenKeystrokes:10

/# UiAutomation will click even on non-visible elements.


UIAutomation.Click \
                Element: Acrobat.Preferences.Button_Line_down \
                ClickType:UIAutomation.ClickType.LeftClick \
                MousePositionRelativeToElement:UIAutomation.RectangleEdgePoint.MiddleCenter \
                OffsetX:0 OffsetY:0
                
UIAutomation.Click \
                Element: Acrobat.Preferences.Button_Line_down \
                ClickType:UIAutomation.ClickType.LeftClick \
                MousePositionRelativeToElement:UIAutomation.RectangleEdgePoint.MiddleCenter \
                OffsetX:0 OffsetY:0
                
UIAutomation.Click \
                Element: Acrobat.Preferences.Button_Line_down \
                ClickType:UIAutomation.ClickType.LeftClick \
                MousePositionRelativeToElement:UIAutomation.RectangleEdgePoint.MiddleCenter \
                OffsetX:0 OffsetY:0
                
wait 2
#/                

UIAutomation.Click \
                Element: Acrobat.Preferences.TreeItem_Signatures \
                ClickType:UIAutomation.ClickType.LeftClick \
                MousePositionRelativeToElement:UIAutomation.RectangleEdgePoint.MiddleCenter \
                OffsetX:0 OffsetY:0
                
                
UIAutomation.Click \
                Element: Acrobat.Preferences.Button_More \
                ClickType:UIAutomation.ClickType.LeftClick \
                MousePositionRelativeToElement:UIAutomation.RectangleEdgePoint.MiddleCenter \
                OffsetX:0 OffsetY:0
                
wait 0.5

UIAutomation.Click \
                Element: Acrobat.Preferences.CheckBox_Review \
                ClickType:UIAutomation.ClickType.LeftClick \
                MousePositionRelativeToElement:UIAutomation.RectangleEdgePoint.MiddleCenter \
                OffsetX:0 OffsetY:0

As you can see from the video below, I have altered the preferences for digital signatures. You should be able to use a similar approach for any PDF software you use that will handle signature validation. Acrobat and Reader can both do this, and I expect the Nuance and NitroPDF offerings will have similar functionality.

Imgur

Regards,
burque505

1 Like

@nutan, I was able to create a very simple Custom Module using GroupDocs that will verify a digital signature, but the GroupDocs trial license (I discovered much to my chagrin) only allows verifying PDFs with one or two pages. For that reason I’m hesitant to post the Custom Module code, but if it will be of use to you I’ll be happy to.

Regards,
burque505

@burque505 thanks i also tried it with appmask i get it from extract data innertext of signed and unsigend is different in my case.

1 Like

That’s an ingenious approach, @nutan! Nice.
Regards,
burque505