iOS - How to programmatically select a signature(with AnnotEditTool)

80 views
Skip to first unread message

Morne Scholtz

unread,
Sep 10, 2014, 8:22:55 AM9/10/14
to pdfne...@googlegroups.com
Hi there,
We are adding a signature to a PDF document, once this signature is added, it needs to be programmatically selected with the AnnotEditTool( in order for the user to place it in the exact position on the document). 

The only way I have found so far, seems to be to simulate a UITapGestureRecognizer at the coordinates for the signature/annotation. I do not like this approach as it seems 'hack-y'

Is there an easier way to accomplish this?
Thank you
Morne

Ryan

unread,
Sep 11, 2014, 2:51:07 PM9/11/14
to pdfne...@googlegroups.com
The Annotation will have been appended to the existing annotations on that page. So you once the tool has added it to the page, you can access it this way.

page = doc.GetPage(x)
sig_annot
= page.GetAnnot(page.GetNumAnnots() - 1) # probably want to double check that there is at least 1 annot...


James

unread,
Sep 11, 2014, 5:18:15 PM9/11/14
to pdfne...@googlegroups.com
Hi Morne,

What Ryan replied is true for accessing a PDF annotation in code, but I believe you are asking how to programmatically trigger a visual selection of an annotation. Unfortunately there isn't currently a built-in mechanism to do this, so your choices would be to use the 'hacky' approach, or to modify the tools code to create a proper way of doing this. The latter will be nicer to use internally, but will make merging in new versions of the tools source code more time consuming. (It is best to subclass when possible.)

That said, having a standard programmatic way to visually select an annotation sounds like a good idea, so we'll try to add this to a future version.

Morne Scholtz

unread,
Sep 15, 2014, 3:11:37 AM9/15/14
to pdfne...@googlegroups.com
Thanks guys,

No problem, I will use the simulation of a gesture recogniser for now and look out for when you add it to the SDK.

Regards,
Morne
Reply all
Reply to author
Forward
0 new messages