I have managed to implement a very basic PDF viewer within my application, but was wondering if it was possible to add annotations to the PDF. I have looked through the SDK docs, but not found anything. I have 2 questions really:
- Is it possible to do this?
- What is the best approach to take?
- Is there a framework or library that I can include to assist with this?
Thanks.
I don't think
PDFAnnotation
or PDFKit were ported to iPhone from the desktop.... probably a great excuse to file a radar. However, Haru may get you by in the meantime.You can do annotation by reading in a PDF page, drawing it onto a new PDF graphics context, then drawing extra content onto that graphic context. Here is some code that adds the words 'Example annotation' at position (100.0,100.0) to an existing PDF. The method getPDFFileName returns the path of the original PD. getTempPDFFileName returns the path of the new PDF, the one that is the original plus the annotation.
To vary the annotations, just add in more drawing code in place of the drawInRect:withFont: method. See the Drawing and Printing Guide for iOS for more on how to do that.
I am working in the stuff and created a GitHub project. Please check it out here.