Page 1 of 1
Activate/Deactivate PencilTool for signature
Posted: Wed Nov 29, 2017 6:16 pm
by dkeith2
I would like to see an example of how to enable/turn on/show the pencil tool on a form, so that I may sign a PDF signature block. The platform could be... Windows with a mouse, windows tablet with a stylus, windows tablet with a touch screen using your finger etc.
The canvas will contain a drawn PDF form with or without form fields.
On command, the user will open a form for editing. When the user needs to sign the form, a button for ex. is made available and the user clicks or otherwise presses the button, the penciltool is activated, and the user signs the document.
How is this done? Is there an example available?
Thank you.
Re: Activate/Deactivate PencilTool for signature
Posted: Wed Nov 29, 2017 7:24 pm
by Sasha - Tracker Dev Team
Hello dkeith2,
Well that's not possible with the CoreApi, because there is no UI Control at all.
You can use the Editor SDK - there you can activate the tool by using the ExecuteUICmd method and giving the ID of the command that activates the pencil tool. You can look for the ID by using the Customize Commands feature of the end user Editor.
Cheers,
Alex
Re: Activate/Deactivate PencilTool for signature
Posted: Wed Nov 29, 2017 7:29 pm
by dkeith2
Ok so I have a TPXV_Inst (Delphi). How do I go from, say, a .Doc[0] instance (or any other interface) to an IUIX_Obj (second parameter of the ExecUICmd procedure)?
Also I'm assuming we're talking about PencilTool - 33129 - Annots:Tool:InkMenuItem?
What about IUIX_Pen? Would that do the trick? If so, can you provide an example of it's use, starting with the IPXV_Inst?
Thank you.
Re: Activate/Deactivate PencilTool for signature
Posted: Wed Nov 29, 2017 7:53 pm
by dkeith2
I've tried:
FInst.ExecUICmd('PencilTool',FInst.ActiveMainFrm.Obj);
FInst.ExecUICmd('Annot.Tool.InkMenuItem',FInst.ActiveMainFrm.Obj);
FInst.ExecUICmd2(33129,FInst.ActiveMainFrm.Obj);
...with an open PDF.
Nothing happens....
Is this documented somewhere?
Re: Activate/Deactivate PencilTool for signature
Posted: Wed Nov 29, 2017 9:36 pm
by dkeith2
Ok, this worked:
FInst.ExecUICmd('cmd.tool.annot.pencil',FInst.ActiveMainFrm.Obj);
Re: Activate/Deactivate PencilTool for signature
Posted: Thu Nov 30, 2017 7:59 am
by Sasha - Tracker Dev Team
Re: Activate/Deactivate PencilTool for signature
Posted: Thu Nov 30, 2017 6:37 pm
by dkeith2
I noticed a problem with this: when I call ExecUICmd('cmd.annots.flatten',Inst.ActiveDoc.ActiveView.PagesView.Obj) it allows me to save the annotations (pencil drawing etc.) with the document. Have to jump through other hoops as well, but the annots are saved with the document.
I thought that if I choose to flatten the annots, they would be 'burned in' to the document and could no longer be edited. However, when I open the doc up in my editor, the annot is still selectable/modifiable. Is this the way it is supposed to work? I need hand drawn signatures to become a permanent, non-editable part of the document. Is there another way to do this?
Thanks.
Re: Activate/Deactivate PencilTool for signature
Posted: Sat Dec 02, 2017 7:27 am
by Sasha - Tracker Dev Team
Hello dkeith2,
There is a command that flattens selected comments only and the command that flattens all of the comments on pages. Be sure to use the needed one.
But in your case, it's better to use the operation directly, as the command launches the options dialog:
https://sdkhelp.pdf-xchange.com/vi ... ts_flatten
Cheers,
Alex
Re: Activate/Deactivate PencilTool for signature
Posted: Sun Dec 03, 2017 12:19 am
by dkeith2
Great, got that working, thank you.
Now I need to figure out how to access the brush for the PencilTool. Here's what I've tried:
Code: Select all
var
i: Cardinal;
coll: IUIX_ObjCollection;
obj: IUIX_Obj;
s: WideString;
IUIX_PencilTool;
begin
coll := FInst.ActiveDocView.Obj.Children;
for i := 0 to Pred(FInst.ActiveDocView.Obj.Children.Count) do
if Assigned(FInst.ActiveDocView.Obj.Children.Item[i]) then
...
but this really doesn't seem to give me access, even thought I'm activating the PencilTool this way:
Code: Select all
Inst.ExecUICmd('cmd.tool.annot.pencil',Inst.ActiveDocView.Obj);
I thought that maybe, just maybe, since the owner of the PencilTool is the ActiveDocView.Obj, perhaps the PencilTool would show up as a child to the .obj... I do find one child of the .obj, but I can't get any class info from it.
Also, in the COM interface wrapper, there is no interface to a 'PencilTool'. I did find a pen, however, but can't seem to activate it.
I need to change the color of the PencilTool's brush, as well as the width. How do I do this?
Thanks.
Re: Activate/Deactivate PencilTool for signature
Posted: Sun Dec 03, 2017 12:40 am
by dkeith2
Also tried this:
Code: Select all
var
i: Cardinal;
coll: IUIX_ObjCollection;
obj: IUIX_Obj;
s: WideString;
brush: IUIX_Brush;
begin
coll := FInst.ActiveDocView.Obj.Children;
for i := 0 to Pred(FInst.ActiveDocView.Obj.Children.Count) do
if Assigned(FInst.ActiveDocView.Obj.Children.Item[i]) then
try
IUIX_Pen(FInst.ActiveDocView.Obj.Children.Item[i]).Get_Brush(brush);
if not Brush.Set_Color0(000000) = S_OK then
raise Exception.Create('Error: Object does not have a brush');
except
MessageDlg('Error: Object does not have a brush',mtError,[mbOK],0);
end;
...
I don't get any errors, and my brush color remains the same. Also tried brush.SetColor1(0) etc. same same.
Re: Activate/Deactivate PencilTool for signature
Posted: Mon Dec 04, 2017 12:38 pm
by Sasha - Tracker Dev Team
Re: Activate/Deactivate PencilTool for signature
Posted: Mon Dec 04, 2017 5:21 pm
by dkeith2
Code: Select all
var
tid: Integer;
styleparms: ICabNode;
hr: HRESULT;
begin
tid := Inst.Str2ID('cmd.tool.annot.pencil',false);
hr := Inst.CommentStylesManager.GetCurrentStyle(tid,styleParms);
if HR = S_OK then
begin
styleparms['SC'].v := RGB(0,0,0);
Inst.CommentStylesManager.OnChangedCurrentStyle(tid);
end;
VerifyFPControlWord;
Inst.ExecUICmd('cmd.tool.annot.pencil',FPencilOwner);
This doesn't change the color of the pencil tool...
Re: Activate/Deactivate PencilTool for signature
Posted: Mon Dec 04, 2017 5:51 pm
by dkeith2
When I changed it to this:
Code: Select all
var
tid: Integer;
styleparms: ICabNode;
hr: HRESULT;
begin
// Pencil Tool command constant - 4216 - cmd.tool.annot.pencil -
VerifyFPControlWord;
tid := Inst.Str2ID('tool.annot.pencil',false);
hr := Inst.CommentStylesManager.GetCurrentStyle(tid,styleParms);
if HR = S_OK then
begin
styleparms['SC'].v := RGB(0,0,0);
Inst.CommentStylesManager.OnChangedCurrentStyle(tid);
end;
Inst.ExecUICmd('tool.annot.pencil',FPencilOwner);
...HR returns S_OK. However I get an EOleException 'The Parameter is incorrect' error here:
Code: Select all
Inst.CommentStylesManager.OnChangedCurrentStyle(4216); // same error if I specify the command constant 4216
Re: Activate/Deactivate PencilTool for signature
Posted: Mon Dec 04, 2017 6:30 pm
by dkeith2
Ok, didn't realize that rgbd was a string value that needed to be quoted. Once I quoted the rgb values as a string, it changed the color successfully:
Code: Select all
styleparms['SC'].v := 'rgbd(0,0,0)';
Now to figure out how to change the width of the stroke...
Thanks.
Re: Activate/Deactivate PencilTool for signature
Posted: Mon Dec 04, 2017 7:00 pm
by dkeith2
In order to set the PencilTool brush size, I've tried this:
Code: Select all
styleparms['S.W'].v := 6.0;
styleparms['SW'].v := 6.0;
styleparms['SW'].v := 6;
styleparms['SW'].v := '6';
styleparms['SW'].v := '6pt';
Have you yet created a reference to the constants list?
What is the PencilTool brush width constant?
"The parameter is incorrect'...
Re: Activate/Deactivate PencilTool for signature
Posted: Tue Dec 05, 2017 8:30 am
by Sasha - Tracker Dev Team
Hello dkeith2,
For this, better use the CabNodeExplorer available from here:
https://www.pdf-xchange.com/forum3 ... 66&t=25943
Or just look into the registry and see the needed values - it's the same but the node explorer itself is much easier to use.
Cheers,
Alex