Q:
We are looking at an option to Render and Edit PDF Forms from within our iPad application using PDFNet SDK (http://www.pdftron.com/pdfnet/mobile/ios_pdf_library.html).
I saw some forms manipulation samples but I am not clear how to implement this in my IOS app.
A: The current iOS build includes most of the API that is available on other platforms (http://www.pdftron.com/pdfnet/apiref.html), and could be used to implement form filling. For example, using the forms API (http://www.pdftron.com/pdfnet/samplecode.html#InteractiveForms and http://www.pdftron.com/pdfnet/samplecode.html#Annotation)
To determine which form or annotation is touched you can use GetAnnotationAt:y:, selector in PDFViewCtrl and PDFView:
/**
- Returns the annotation present at screen coordinates (x, y). If no annotation is present,
- callling IsValid on the returned annotation will return false.
- You must lock the doc when retrieving an annotation.
- @param x - Number of seconds between refreshes.
- @param y - Number of seconds between refreshes.
-
@return the annotation present at screen coordinates (x, y).
/
-(Annot)GetAnnotationAt: (int)x y: (int)y;
Here is a code snippet showing example usage in the context of a PDFViewCtrl:
- (BOOL)handleTap:(UITapGestureRecognizer )gestureRecognizer
{
Annot myAnnot;
CGPoint down = [gestureRecognizer locationInView:pdfViewCtrl];
[pdfViewCtrl becomeFirstResponder];
int pn = [pdfViewCtrl GetPageNumberFromScreenPt:down.x y:down.y];
if( pn < 1 )
{
return NO;
}
PDFDoc* doc = [pdfViewCtrl GetDoc];
[doc Lock];
myAnnot = [pdfViewCtrl GetAnnotationAt:down.x y:down.y];
[doc Unlock];
If( [myAnnot IsValid] )
{
NSLog(@”Found a valid annotation.”);
return YES;
}
else
NSLog(@”No valid annotation.”);
return NO;
}