PDF-XChange - Tracker PDF Viewer - TIFF-XChange - Image-XChange - XMF-XChange - Raster-XChange - Support

Moderators: TrackerSupp-Daniel, Tracker Support, Chris - Tracker Supp, Vasyl-Tracker Dev Team, Paul - Tracker Supp, Ivan - Tracker Software, Sean - Tracker, 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.
 
lidds
User
Topic Author
Posts: 334
Joined: Sat May 16, 2009 1:55 pm

Draw area for digital signature...

Thu Nov 30, 2017 4:37 pm

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


Thanks

Simon
 
lidds
User
Topic Author
Posts: 334
Joined: Sat May 16, 2009 1:55 pm

Re: Draw area for digital signature...

Fri Dec 01, 2017 4:03 pm

Anyone have any ideas on how to do this?
 
User avatar
Sasha - Tracker Dev Team
User
Posts: 3277
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Draw area for digital signature...

Fri Dec 01, 2017 4:55 pm

Hello Simon,

Have you tried using the End-User Editor to find an analogy of what you need?

Cheers,
Alex
Join us at Google+:
https://plus.google.com/+PDFXChangeEditorTS
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
 
lidds
User
Topic Author
Posts: 334
Joined: Sat May 16, 2009 1:55 pm

Re: Draw area for digital signature...

Fri Dec 01, 2017 6:13 pm

Alex,

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.

Hope that makes sense

Thanks

Simon
 
User avatar
Sasha - Tracker Dev Team
User
Posts: 3277
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Draw area for digital signature...

Fri Dec 01, 2017 8:13 pm

Hello Simon,

Will the user draw that area somehow?
I think the Signature Field will work for you. Go to edit form tool - you can add it from there.

Cheers,
Alex
Join us at Google+:
https://plus.google.com/+PDFXChangeEditorTS
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
 
lidds
User
Topic Author
Posts: 334
Joined: Sat May 16, 2009 1:55 pm

Re: Draw area for digital signature...

Fri Dec 01, 2017 9:00 pm

Alex,

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??

Thanks

Simon
 
User avatar
Sasha - Tracker Dev Team
User
Posts: 3277
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Draw area for digital signature...

Sat Dec 02, 2017 7:29 am

Hello Simon,

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?

Cheers,
Alex
Join us at Google+:
https://plus.google.com/+PDFXChangeEditorTS
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
 
lidds
User
Topic Author
Posts: 334
Joined: Sat May 16, 2009 1:55 pm

Re: Draw area for digital signature...

Sat Dec 02, 2017 10:55 am

I would like the user to draw in the editor control a region / area

Thanks

Simon
 
User avatar
Sasha - Tracker Dev Team
User
Posts: 3277
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Draw area for digital signature...

Sat Dec 02, 2017 12:09 pm

Hello Simon,

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.

Cheers,
Alex
Join us at Google+:
https://plus.google.com/+PDFXChangeEditorTS
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
 
lidds
User
Topic Author
Posts: 334
Joined: Sat May 16, 2009 1:55 pm

Re: Draw area for digital signature...

Sat Dec 02, 2017 12:31 pm

Thanks Alex, I'll give this a go later today.
 
User avatar
Sasha - Tracker Dev Team
User
Posts: 3277
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Draw area for digital signature...

Sat Dec 02, 2017 12:33 pm

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.

Cheers,
Alex
Join us at Google+:
https://plus.google.com/+PDFXChangeEditorTS
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
 
lidds
User
Topic Author
Posts: 334
Joined: Sat May 16, 2009 1:55 pm

Re: Draw area for digital signature...

Sun Dec 03, 2017 10:13 am

Hi Alex,

Stuggling with getting the IPXV_PageRectSelection of the snapshot tool, obviously doing something wrong as I get the following error:

Error [System]: Invalid pointer

I am using the following code:

        ElseIf e.nEventID = nIDS(CInt(IDS.e_docSelection_changed)) Then
            Try
                Dim Doc As PDFXEdit.IPXV_Document = CType(e.pFrom, PDFXEdit.IPXV_Document)
                Dim docSel As IPXV_DocSelection = Doc.GetSel(1)
                Dim prs As IPXV_PageRectSelection = CType(docSel, IPXV_PageRectSelection)
                Console.WriteLine(prs.PageRect.bottom.ToString & " " & prs.PageRect.top.ToString)

                e.pEvent.Result = 1
                e.pEvent.Handled = True
            Catch ex As Exception
                Console.WriteLine(convertErr(ex))

                e.pEvent.Result = 1
                e.pEvent.Handled = True
            End Try


Any help would be appreshiated.

Thanks

Simon
 
User avatar
Sasha - Tracker Dev Team
User
Posts: 3277
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Draw area for digital signature...

Mon Dec 04, 2017 12:43 pm

Hello Simon,

And what is Doc.GetSel(1)?
The correct code is:
int nSel = pdfCtl.Inst.Str2ID("selection.pageRect");
PDFXEdit.IPXV_DocSelection docSel = pdfCtl.Doc.GetSel(nSel);


Cheers,
Alex
Join us at Google+:
https://plus.google.com/+PDFXChangeEditorTS
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
 
lidds
User
Topic Author
Posts: 334
Joined: Sat May 16, 2009 1:55 pm

Re: Draw area for digital signature...

Wed Dec 06, 2017 8:45 am

Alex,

Thanks this worked perfectly.

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)?

Thanks

Simon
 
User avatar
Sasha - Tracker Dev Team
User
Posts: 3277
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Draw area for digital signature...

Thu Dec 07, 2017 1:44 pm

Hello Simon,

I believe I've already answered this one:
viewtopic.php?f=66&t=29286&p=114625&hilit=Cursor#p114625

Cheers,
Alex
Join us at Google+:
https://plus.google.com/+PDFXChangeEditorTS
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
 
lidds
User
Topic Author
Posts: 334
Joined: Sat May 16, 2009 1:55 pm

Re: Draw area for digital signature...

Thu Dec 07, 2017 4:26 pm

Sorry Alex, my mistake, forgot I asked this
 
lidds
User
Topic Author
Posts: 334
Joined: Sat May 16, 2009 1:55 pm

Re: Draw area for digital signature...

Thu Dec 07, 2017 4:55 pm

Alex,

I have tried the following code, but it does not change the icon?? I have also tried it in:

e_operBeforeExecute
e_operExecuted

but nothing happens

    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


Thanks

Simon
 
User avatar
Sasha - Tracker Dev Team
User
Posts: 3277
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: Draw area for digital signature...

Sat Dec 09, 2017 6:59 am

Hello Simon,

For this you will have to implement and use the Custom Event Handler and use it carefully:
      //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.

Cheers,
Alex
Join us at Google+:
https://plus.google.com/+PDFXChangeEditorTS
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ

Who is online

Users browsing this forum: No registered users and 1 guest