Need Help with op.document.addDigitalSignature  SOLVED

PDF-XChange Editor SDK for Developers

Moderators: TrackerSupp-Daniel, Tracker Support, Paul - Tracker Supp, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, Ivan - Tracker Software, Tracker Supp-Stefan

Forum rules
DO NOT post your license/serial key, or your activation code - these forums, and all posts within, are public and we will be forced to immediately deactivate your license.

When experiencing some errors, use the IAUX_Inst::FormatHRESULT method to see their description and include it in your post along with the error code.
prime clinical systems
User
Posts: 211
Joined: Sun Aug 05, 2012 5:20 pm

Need Help with op.document.addDigitalSignature

Post by prime clinical systems »

Hi, please refer to this original post where I got it to work: https://forum.pdf-xchange.com/ ... 66&t=28933
What I want to do is get the Signature Graphic from Icon File to show, using file based pfx certificates, and obviously I'm doing something wrong
Code from above mentioned post although worked did not include any code to get the graphic signature file, so I tried this first, but gives Invalid procedure call/arguments error
Options("GraphicType").v = 1
Options("GraphicName").v = "C:\Users\Public\" & UserName & "\" & UserName & ".bmp"
I see that one needs to probably define a dictionary, is that another Cab? I could not find help on this stuff at all except this page: https://sdkhelp.pdf-xchange.com/vie ... meStamping, but nothing on how to make the dictionary, I just assumed that all options were available
so then I tried messing with predefined templates in the table which include Graphic Signature, none of this worked
My Default Definition includes a Signature Icon specified in the Path of the Signature prefences for the Default Template, and when I leave out these following two lines, which were not present in the original post, the signature graphic does NOT show, rather just the Printed Name on the left side, so attempting to specify the exact template I added these two lines, and errors out with Invalid Procedure Call.
Options("TemplateIdx").v = -1 which is for default (I also tried 0 assuming zero based index) since Default is the first entry in the list and did not work either. Not sure why one would need the Index if specifying a name however.
Options("Name").v = "Default"

So I cloned the Default one, named it "MySig" and is the 5th template in the listbox So I tried this and get the same error.
Options("TemplateIdx").v = 4
Options("Name").v = "MySig"

Also, to just use the Custom Template Option it says it uses this, but this gives same error, invalid procedure call etc.
Options("HasTemplate").v = True
But to add a Template Dictionary type I would like an example on how to do that, with settings as below

I'm defining my Default template in the list box to have the following:
Show Graphics Section:
Custom Icon with full path to the bmp file
Display Logo
Show Text: section
Name, Date, Labels
Text Direction "Auto"

Thanks
CE
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am

Re: Need Help with op.document.addDigitalSignature

Post by Sasha - Tracker Dev Team »

Hello Clifford,

I've spoke with the developer who implemented this operation. He said that there was a non-implemented possibility that you could not pass the icon of the signature's template appearance through the CAB. He said that they will try to fix this until this release, though this is not a 100% guarantee.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
prime clinical systems
User
Posts: 211
Joined: Sun Aug 05, 2012 5:20 pm

Re: Need Help with op.document.addDigitalSignature

Post by prime clinical systems »

well, then why can't you select a predefined template, by name or index, at least, at that stores the users predefined graphic file, so you are saying absolutely no way to make this work besides popping up the digital signature selection screen? If not, then fine, I'll let that popup in the event, just wanted to have this streamlined, as users complain about too many clicks to sign a document, and I really think one of these options either the template index/name or the actual operation itself should work. One spends so much time, then I wait another 3 days for an answer just to find out that it is not implemented yet. very frustrating to say the least. Sounds like only option is to delete the signature field and convert to a stamp annotation. Hopefully the stamped annotation allows text so I can add the date/time

CE
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am

Re: Need Help with op.document.addDigitalSignature

Post by Sasha - Tracker Dev Team »

Hello Clifford,

Please provide a full operation code sample that you are testing right now - we suspect that you have not set some CAB field - that's all. Also, in future, please specify what exactly the error was (the HRESULT with the FormatHRESULT output). All of this will greatly speed up the answer.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
prime clinical systems
User
Posts: 211
Joined: Sun Aug 05, 2012 5:20 pm

Re: Need Help with op.document.addDigitalSignature

Post by prime clinical systems »

I just sent in to Stefan Dzhukelov, 5 min ago, and VB does not give errors like that.. Error 5 is Invalid procedure call or argument, and nothing else available. And I hope it is something simple please check here is link to the project anyway
https://www.dropbox.com/s/547tpkvint3f8 ... t.zip?dl=0
prime clinical systems
User
Posts: 211
Joined: Sun Aug 05, 2012 5:20 pm

Re: Need Help with op.document.addDigitalSignature

Post by prime clinical systems »

Hi well, after more trial and error, found that you have to enter cab options like this, but sadly, the graphic does not insert, so will continue to play around with existing templates and same thing to see what happens, just with there was some documentation that shows how dictionary items all have to entered in Name.Name.Name fashion.
Options("SignatureAppearance.HasTemplate").v = True
Options("SignatureAppearance.Template.GraphicType").v = 1
Options("SignatureAppearance.Template.GraphicName").v = App.Path & "\sig.bmp"
Options("SignatureAppearance.Template.TextDirection").v = 0
Options("SignatureAppearance.Template.ShowName").v = True
Options("SignatureAppearance.Template.ShowDate").v = True
Options("SignatureAppearance.Template.ShowLabels").v = True
Options("SignatureAppearance.Template.ShowLogo").v = True

Also tried with hastemplate false, found that if you have graphic > 200 pixels wide, won't work, inserts a blank box, even though looks fine in signature setup view, but if size to 198 wide it works
Options("SignatureAppearance.TemplateIdx").v = 0 'I assume the first template idx is 0

In summary two bugs, the graphic won't insert at all with the HasTemplate = true, and when using the HasTemplate = false, you need to resize the graphic so not more than 200 pixels wide, as programmer has no way of knowing this, because in signature preview in setup it looks perfect.
ce
Capture1.JPG
P.S.
Ok hate to be a pest, but try the compiled version in the folder and it does not hold the pre-inserted signature, and does not work on re-opening the project, too many bugs right now in this routine, I sure hope they can fix, otherwise, I just abandon graphic I guess, and remove the placeholder field and change to annotation stamp.
https://www.dropbox.com/s/lp66towsy0gw4 ... 9.zip?dl=0


ce
You do not have the required permissions to view the files attached to this post.
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am

Re: Need Help with op.document.addDigitalSignature

Post by Sasha - Tracker Dev Team »

Hello Clifford,

1) Download a latest Dev. Build from here:
https://www.pdf-xchange.com/forum3 ... 66&t=25943
2) The code with the Template ID should work correctly:

Code: Select all

private void AddSignatureByIndex(IPXV_Inst Inst, IPXV_Document Doc)
{
	int nID = Inst.Str2ID("op.document.addDigitalSignature", false);
	IOperation Op = Inst.CreateOp(nID);
	ICabNode input = Op.Params.Root["Input"];
	input.Add().v = Doc;
	ICabNode options = Op.Params.Root["Options"];
	options["PageNumber"].v = 0;
	options["UseFileCertificate"].v = true;
	options["DigiSigType"].v = 1;
	options["FileCertificate"].v = @"D:\111111.pfx";
	options["CertificatePassword"].v = "111111";
	options["AskDestinationFileName"].v = true;
	ICabNode appear = options["SignatureAppearance"];
	appear["HasTemplate"].v = false;
	appear["TemplateIdx"].v = 4;
	Op.Do();
}
3) The native code for the HasTemplate = true was updated though there is a bug with small images. Meaning that if you specify a big image (like 1000*500) everything should work fine. If the image would be smaller then after reopening the size of the page will be changed - we know about this one and will try to fix this till the next release. If not - stick with AddSignatureByIndex for some time. Here's the code that works now with big images:

Code: Select all

private void AddSignatureWithTemplate(IPXV_Inst Inst, IPXV_Document Doc)
{
	int nID = Inst.Str2ID("op.document.addDigitalSignature", false);
	IOperation Op = Inst.CreateOp(nID);
	ICabNode input = Op.Params.Root["Input"];
	input.Add().v = Doc;
	ICabNode options = Op.Params.Root["Options"];
	options["PageNumber"].v = 0;
	options["UseFileCertificate"].v = true;
	options["DigiSigType"].v = 1;
	options["FileCertificate"].v = @"D:\111111.pfx";
	options["CertificatePassword"].v = "111111";
	options["AskDestinationFileName"].v = true;
	ICabNode appear = options["SignatureAppearance"];
	appear["HasTemplate"].v = true;
	ICabNode tmplt = appear["Template"];
	tmplt["GraphicType"].v = 2;
	tmplt["GraphicName"].v = @"D:\TestImage.bmp";
	tmplt["ShowName"].v = true;
	tmplt["ShowDate"].v = true;
	Op.Do();
}
I will notify you when we will have this fixed so you can try this.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am

Re: Need Help with op.document.addDigitalSignature

Post by Sasha - Tracker Dev Team »

Hello Clifford,

We've fixed this bug. I've deployed another Dev. build - please download it from the same link I mentioned before and try it - the first and second code sample should work. To test it you can use the FullDemo application (you will need to add a custom button on a form to call this code) before translating it to VB6.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
prime clinical systems
User
Posts: 211
Joined: Sun Aug 05, 2012 5:20 pm

Re: Need Help with op.document.addDigitalSignature

Post by prime clinical systems »

Hi well, I downloaded the new dev build, and with indexed template will only show the sig graphic inside the IDE, compile the project and still does not work, just a blank box.
ce
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am

Re: Need Help with op.document.addDigitalSignature

Post by Sasha - Tracker Dev Team »

Hello Clifford,

Have you tried the samples I mentioned above?

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
prime clinical systems
User
Posts: 211
Joined: Sun Aug 05, 2012 5:20 pm

Re: Need Help with op.document.addDigitalSignature

Post by prime clinical systems »

neither code sample works now with this build, just shows blank box, not even name, labels, nothing just blank text.
Here is source to complete sample code
https://www.dropbox.com/s/pgl0ohsgb7yxz ... t.zip?dl=0

Also please confirm that the signature template idx is 0 for the default, tried 0-4 nothing worked, and I need to use the default always as otherwise I would never know in code which one the user wants to use, since I don't show any dialogs when signing.
Capture.JPG
You do not have the required permissions to view the files attached to this post.
prime clinical systems
User
Posts: 211
Joined: Sun Aug 05, 2012 5:20 pm

Re: Need Help with op.document.addDigitalSignature

Post by prime clinical systems »

Please, need to find out if fix coming or not, as neither method works, thanks
ce
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am

Re: Need Help with op.document.addDigitalSignature

Post by Sasha - Tracker Dev Team »

Hello Clifford,

Right now I'm making a demo project for you - it will be ready in a couple of hours.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am

Re: Need Help with op.document.addDigitalSignature

Post by Sasha - Tracker Dev Team »

Hello Clifford,

I've made a project with the manifest (that uses the dll that lies near the exe file) - this will assure that it will work correctly independently of the dll that you have on your system. It uses the 322 build dll that was launched today.

Cheers,
Alex
You do not have the required permissions to view the files attached to this post.
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
prime clinical systems
User
Posts: 211
Joined: Sun Aug 05, 2012 5:20 pm

Re: Need Help with op.document.addDigitalSignature

Post by prime clinical systems »

ok same as my vb6 project, as stated before it works inside the IDE, but the compiled version, no, just a blank box
Capture.JPG
again here are the source files, load into IDE and work, run the compiled exe, and just blank box.
ce
You do not have the required permissions to view the files attached to this post.
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am

Re: Need Help with op.document.addDigitalSignature

Post by Sasha - Tracker Dev Team »

Hello Clifford,

Everything works for me:
Signature.gif
Also, when I clicked Sign PDF in your project, everything worked for me:
Capture.PNG
Cheers,
Alex
You do not have the required permissions to view the files attached to this post.
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
prime clinical systems
User
Posts: 211
Joined: Sun Aug 05, 2012 5:20 pm

Re: Need Help with op.document.addDigitalSignature

Post by prime clinical systems »

Well, the problem I guess is when there was previously a signature in the same place, as the picture you show, shows that indeed a blank box was added, but now when I replaced the PDF with another one, that had never been signed, it worked just fine, so anyway, seems so long as document has not been saved, and you delete the sig, it will work, but for 99% of the needed use this probably won't come up, but anyway, try what I'm saying, clear the sigs, edit and click on the blank box, remove it, then sign again, I get the blank box.
CE
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am

Re: Need Help with op.document.addDigitalSignature

Post by Sasha - Tracker Dev Team »

Hello Clifford,

Please use some kind of a screen capture utility like http://www.screentogif.com/ that I'm using, and capture the exact steps that you are doing (preferably in my C# project) so that I can reproduce them and try to solve this.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
prime clinical systems
User
Posts: 211
Joined: Sun Aug 05, 2012 5:20 pm

Re: Need Help with op.document.addDigitalSignature

Post by prime clinical systems »

No worries for now, since I'm locking the signature box anyway after signing, cannot be reversed, this will not be an issue, I can't replicate with your compiled c-sharp project, so definitely vb6 related, but I just won't allow it to happen and be done with this, thanks
ce
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am

Re: Need Help with op.document.addDigitalSignature  SOLVED

Post by Sasha - Tracker Dev Team »

:)
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ