By default, jPDFNotes saves annotations within the PDF document. Qoppa’s PDF tools are fully compliant with the PDF format specs, so all annotations created by jPDFNotes are usable by other PDF applications (such as Adobe Reader), and vice-versa.
The PDF format also defines two other file formats to store annotations separate from the PDF document, they are FDF and XFDF.
jPDFNotes can save the annotations in a document to FDF or XFDF formats:
PDFNotesBean bean = new PDFNotesBean(); bean.loadPDF ("c:\\test.pdf"); // export annotations as an XFDF file (can also export to output stream) bean.getMutableDocument().exportAnnotsAsXFDF("c:\\annots.xfdf"); // export annotations as an FDF file (can also export to output stream) bean.getMutableDocument().exportAnnotsAsFDF("c:\\annots.xfdf");
jPDFNotes can also read annotations and merge into a document from FDF and XFDF:
// import annotations from XFDF from a file (can also read from input stream) bean.getMutableDocument().importAnnotsFromXFDF("c:\\annots.xfdf"); // import annotations from FDF from a file (can also read from input stream) bean.getMutableDocument().importAnnotsFromXFDF("c:\\annots.xfdf");
The sample applet that we provide with jPDFNotes, PDFWebNotes, offers convenient ways (no coding needed) to merge annotations from external files as well as save annotations only back to the web server.
Merging annotations into a PDF document on load using PDFWebNotes
Two of the parameters that PDFWebNotes can take on startup are:
MergeFDF – A URL to annotations in FDF format to merge into the document on load.
MergeXFDF – A URL to annotations in XFDF format to merge into the document on load.
PDFWebNotes will first load the PDF document, and then, if either of these parameters are present, PDFWebNotes will read the annotations from the URLs and then merge the annotations in the PDF document that was just loaded, essentially a real-time merge that is transparent to the end user.
Exporting and saving annotations from a PDF document using PDFWebNotes
To save annotations only (and not the PDF document) in these formats requires some entries in the Config.xml file that can be passed to PDFWebNotes. Under the root element of the config.xml file, there can be an element called “Save” to configure save options. This sample file config.xml attached below tells PDFWebNotes to save annotations only using FDF as the save format.
When the user presses the save button on the toolbar, PDFWebNotes will get annotation data from the document, create FDF content and then send that to the SaveURL.