In iOS platform (swift):
How can I get the Id of an annotation when tapping it on screen?
I tried this so far:
When I create the annotation on page, I make sure that the setAsAnnotation is “true” and double check that the annotation.isValid is true. Also when I extract the Fdf string of doc, the annotation is written properly.
When I select the annotation, the selection box is displayed, however I always get the following false “isValid” condition.
`
// Event fired when user taps on the Document
func pdfScrollViewTap(_ gestureRecognizer: UITapGestureRecognizer!) {
// Get tap Coordinates in Page
var curPage = ctrl.getCurrentPage()
let location = gestureRecognizer.location(ofTouch: gestureRecognizer.numberOfTouches-1, in: ctrl)
var locatPTPDF: PTPDFPoint = PTPDFPoint.init(px: Double(location.x), py: Double(location.y))
let newCoord = ctrl.convScreenPt(toPagePt: locatPTPDF, page_num: curPage)
// Get annotation near the tap location
self.doc?.lockRead()
let AnnotSelect : PTAnnot = ctrl.getAnnotationAt(Int32((newCoord?.getX())!), y: Int32((newCoord?.getY())!), distanceThreshold: 22.0, minimumLineWeight: 10.0)
// Is there an annotation near the tap location? PROBLEM: ALWAYS FALSE ///////////////////
if AnnotSelect.isValid() == true {
print(“THIS IS A VALID ANNOT”)
print(AnnotSelect.getUniqueID().getAsPDFText())
}else{
print(“NOT A VALID ANNOT”)
}
`