PDFNet for iOS/Android Annotation Questions

Q: Background: Our app has a web cousin. Users can use web or IOS app
to upload documents and do annotations. Users can do annotations on
our web product using our own annotation tool. They can then download
an annotated PDF down to IOS app. We would like to enable annotation
on this downloaded version using PDFTron library. This version of
document will keep changing on the device as and when user chooses to
download the latest annotated copy from the web. We would like to hold
the annotations made on the IOS device inside the app and display it
on the document and bake it in the document only when user chooses to
print or export the document out from IOS app. So here is an example:

  1. Document a-web.pdf gets loaded on web.
  2. User annotates document on web
  3. User downloads the annotated copy to device let’s call this copy as
    a-web-ios.pdf.
  4. User then makes annotations locally on the device using PDFTron
    library.
  5. User goes back to web and does more annotation on the web and then
    downloads the copy again to device, let’s call it a-web-ios-v2.pdf.
  6. User will see all the annotations he/she made on as a-web-ios.pdf
    on top of a-web-ios-v2.pdf.
  7. User then exports/print the document from IOS app and gets a copy
    that has all device based annotations baked in the a-web-ios-v2.pdf
    document.

I hope it is making sense and I am not confusing you. Please note that
we will not be re-uploading local copy back to web.

Now
We are currently exploring our options on how to approach the
annotations made within our iOS application. Currently you can
download new versions of the original PDF from our backend (as
explained above). Because of this, the locally modified PDF would be
overwritten and the annotations made by PDFNet lost. Are the
annotations in PDFNet designed to be storable outside of the actual
PDF file, say in core data, so they could be re-applied to an updated
source document? If so, do you have any pointers/sample code on how to
do it. You were a huge help in pointing us in the right direction with
search. We also need help in terms of direction and sample code for
following:

  1. UI and functionality to change pen color and thickness.
  2. Enter text as typewriter. Text as stamp.
  3. Enter text as pert of yellow sticky notes and then edit it later.
  4. Enter a free hand draw mode that enables continuous writing till I
    quit the mode.
  5. Changing colors for underline, squiggly etc from standard yellow to
    any color that user wants to choose.
  6. Eraser to erase annotations.
  7. Edit existing annotations.
  8. Export all annotations made locally as json object.

I know that these are many questions however I will truly appreciate
your guidance as we are trying to get the product out asap for our
critical client.


A:

Annotation objects have all of the getter and setters needed to create
a custom serializing system. PDFNet does not have built-in annotation
serializing at this time. To address your numbered questions:

  1. UI and functionality to change pen color and thickness.

The sample app’s built in annotation creation functionality allows you
to change the color and thickness of an annotation. Notice that after
the properties have been changed, subsequent annotations are created
with the same values for color and thickness. The functionality is
implemented in libTools.a, and as customers are provided with the
source code for libTools.a, they are able to completely customize the
behaviour. Customizations may include implementing a new UI or
changing how the color and thickness of a new annotation is selected.

  1. Enter text as typewriter. Text as stamp.

PDFNet supports both of these types of annotations (AnnotType
e_FreeText and e_Stamp), so creating them would be a matter of
implementing a UI and calling PDFNet methods at the appropriate times.
For guidance, I would suggest looking at the annotation creation tools
source code, and the Annotation sample project.

  1. Enter text as pert of yellow sticky notes and then edit it later.

The sample app implements this via libTools.a. If you click a sticky
note and choose Open from the UIMenuController, a UIPopoverController
will present the contents of the note and allow it to be edited and
saved. With the source code for libTools.a, you can see exactly how it
is implemented and make any changes needed for your app.

  1. Enter a free hand draw mode that enables continuous writing till I
    quit the mode.

The sample app implements a free hand drawing tool that switches back
to document panning after the annotation has been created. Using the
source code for libTools.a, it is trivial to change the behaviour to
keep the drawing lines in response to touch events. That said, we do
plan on adding support for remaining in a chosen tool in an upcoming
version of libTools.a.

  1. Changing colors for underline, squiggly etc from standard yellow to
    any color that user wants to choose.

In the sample app, if you click on a underline, squiggly etc.
annotation, one of the menu items is “Color”, which when touched
presents a color picker, allowing the user to change the color to any
color.

  1. Eraser to erase annotations.

PDFViewCtrl. includes the selector GetAnnotationAt:y: that allows you
to quickly determine if there is an annotation present where the user
has touched. You could use it to help implement an eraser tool that
erases any annotation that the user touches or moves their finger
over.

  1. Edit existing annotations.

PDFNet allows you to edit any annotation property. For example code,
please see the tools source code and the Annotation example project
(http://www.pdftron.com/pdfnet/samplecode/AnnotationTest.m).

  1. Export all annotations made locally as json object.

Annotation objects have all of the getter and setters needed to create
a custom serializing system, including into JSON objects. PDFNet does
not have built-in annotation serializing at this time.