Processing Annotations and Forms
Once users create markup annotations and fill in form fields, you will want to manage and process this
data. The sections below we discuss how to save, load and merge annotation data in WebViewer.
Loading Annotations and Form Fields
The WebViewer works by loading XOD files, therefore the user needs to convert the PDF source
document into a XOD document first. During the convert process, an XFDF file is embedded into the
XOD document, which stores all the existing annotations, links, and form data of the PDF document.
When a XOD document is first loaded into the PDFTron WebViewer, it looks into the internal XFDF
embedded into the XOD document itself during the convert process, and uses that XFDF to load all of
the following stored in the XFDF: annotations, links, and form field widgets. Please note that the query
parameter 'a', which specifies whether annotations are enabled or not, must be set to 1 so that both
annotations and widgets are loaded in the viewer.
While the user can provide an external XFDF file to load annotations from in the onDocumentLoaded()
callback function in ReaderControl.js, it is important to note that this external XFDF file would replace
the internal XFDF file as the source of annotations and form data loading. That is, only the annotations
and widgets stored in the external XFDF would get loaded, while the internal XFDF would be ignored.
Therefore, if the original PDF document contains an AcroForm, the external XFDF the user provides
must contain the form field widgets information inside it as well so that the PDFTron WebViewer can
recreate the form field widgets.
Exporting Annotations and Form Fields
The WebViewer allows multiple methods of exporting annotations and form fields in order to
accommodate the different needs of users. Both annotations and form field data are exported into one
single XFDF file. Here are the 3 most common methods to export annotations.
Export to XFDF as local download
The user can download the XFDF file containing the annotations and form data of the document
directly from the WebViewer, by the use of dataURLs.
© 2002-2013 PDFTron Systems, Inc.