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.
I am using the following code to automatically add a digital signature to a file, this all works fine. However what I want to do is allow the user to define an area region on the document as to where they want to place the signature. I was wondering how I would do this?
Private Sub OneClickDigitalSignature(ByVal Inst As IPXV_Inst, ByVal Doc As IPXV_Document)
Try
Dim docOID As Guid = getActiveDocOID()
Dim nID As Integer = Inst.Str2ID("op.document.addDigitalSignature", False)
Dim Op As IOperation = Inst.CreateOp(nID)
Dim input As ICabNode = Op.Params.Root("Input")
input.Add().v = Doc
Dim options As ICabNode = Op.Params.Root("Options")
options("PageNumber").v = 0
options("Certificate").v = "3F26DA34FB7566A7147897F44BB63A43BDBE9F68"
'options("UseFileCertificate").v = True
' 0 = Unknown
' 1 = Approval Signature
' 2 = Certification signature
' 3 = Timestamp signature
options("DigiSigType").v = 1
'options("FileCertificate").v = "D:\vb.net\PDFTracker\AddDigitalSignature\AddDigitalSignature\AddDigitalSignature\111111.pfx"
'options("CertificatePassword").v = "Dragnetadmin1"
options("AskDestinationFileName").v = False
options("DestinationFileName").v = MISData.Instance.TempDirectory & "\" & docOID.ToString.ToUpper & ".pdf"
' 1 = No changes to the document shall be permitted; any change to the document shall invalidate the signature
' 2 = Permitted changes shall be filling in forms, instantiating page templates, and signing; other changes shall invalidate the signature
' 3 = Permitted changes shall be the same as for 2, as well as annotation creation, deletion, and modification; other changes shall invalidate the signature
options("DocMDP").v = 2
Dim appear As ICabNode = options("SignatureAppearance")
appear("HasTemplate").v = True
' I am the author of this document
' I agree to the specified portions of this document
' I have reviewed this document
' I am approving this document
' I attest to the accuracy and integrity of this document
' I agree to the terms defined by the placement of my signature on this document
appear("Reason").v = "I am professional engineer"
Dim tmplt As ICabNode = appear("Template")
tmplt("GraphicType").v = 2
tmplt("GraphicName").v = "D:\vb.net\PDFTracker\AddDigitalSignature\AddDigitalSignature\AddDigitalSignature\rosette.png"
tmplt("ShowName").v = False
tmplt("ShowDate").v = False
tmplt("ShowLocation").v = False
tmplt("ShowReason").v = False
tmplt("ShowDistinguishedName").v = False
tmplt("ShowLabels").v = False
tmplt("ShowSubjectName").v = False
tmplt("ShowEditorVersion").v = False
Dim timeStamp As ICabNode = options("TimeStamping")
timeStamp("Enabled").v = True
Dim timeStampData As ICabNode = timeStamp("Data")
timeStampData("URL").v = "https://ca.signfiles.com/TSAServer.aspx"
Op.Do()
Catch ex As Exception
MsgBox(convertErr(ex))
End Try
End Sub
Basically what my client wants is a one click digital signature, which I have coded with help from the forum (see code in earlier post) but what I am struggling with is allowing the user to define an area on the PDF that they want the signature. Once they have done that I can get the bounds of the defined area and pass that into my code to place the digital signature in that area.
I was thinking of allowing the user to define an annotation rectangle get the coordinates of it and delete after. However this is one messy, and also I think would invalidate any earlier digital signatures that were placed as the document would have been modified?
So to recap all I want to do is allow the user to define an area that I can get the coordinates of without modifying the PDF.
Not in front of the computer at the moment but I think the signature form field launches your form, where I want to insert the signature in my custom code in that area and I could not find a operation to intercept??
Then again, how the user will define an area of the signature - will he just use your form and several edits to input the coordinates? Or will he draw in the Editor control?
Well then the Snapshot Tool can work for this matter - it defines a IPXV_PageRectSelection type basically allowing you to get it as a signature placement rectangle. And also, the benefit of the snapshot is that the PDF document itself is not being modified.
Additionally you can customize the snapshot's command icon and text so that it would match your criteria. Even better - create your own command that would use the snapshots handler in the overloaded methods so that you could see when your command executes.
Just one last question. When I execute the cmd.tool.snapshot it changes the cursor icon to a camera, is there anyway that I can change this to match the cursor icon that is displayed when placing a digital signature (the one with a rectangle and pencil)?
Public Sub RunOneClickDigitalSignature()
Dim cmd As PDFXEdit.IUIX_Cmd = uiInst.CmdManager.Cmds.Find("cmd.tool.snapshot")
Me.docPreview.Inst.ExecUICmd2(cmd.ID)
uiInst.SetCursor(uiInst.GetCursorID("pen"))
End Sub
//Event listener that listens for all of the needed events
public void OnEvent(PDFXEdit.IUIX_Obj pSender, PDFXEdit.IUIX_Event pEvent)
{
//If the event is not handled then it will be
pEvent.Handled = false;
//
if (pEvent.Code == (int)0x200) //WM_MOUSEMOVE
{
Parent.uiInst.SetCursor(Parent.uiInst.GetCursorID("pen"));
pEvent.Handled = true;
}
//Target that will contain the custom event handler implementation for the given object
public CustomEventTarget myEventTarget = null; //PS: Do not forget to dispose of it
private void initilaizeCustomEventListenerToolStripMenuItem_Click(object sender, EventArgs e)
{
//Creating the drop target and filling it's supported formats
myEventTarget = new CustomEventTarget(pdfCtl.Doc.ActiveView.PagesView.Obj, this);
}
Basically you will have to create the custom event target when you activate the snapshot tool and dispose of it when you finish using it.