PDF Annotation Magic
Moving annotations from one PDF to another
Annotations, or “markups” on a PDF can be lines, arrows, circles, text boxes, and stamps, among other types. The markups can vary immensely, especially with stamps, because custom stamps can be created with unlimited imagery and detail. In my Privileged Context series I alluded to other uses for importing and exporting FDFs, besides populating form fields. Last weeks post explained how to populate a dropdown list by importing a custom FDF file (I know, “file” is redundant - see PIN number and ATM machine).
The document method exportAsFDF( ) has six optional parameters:
bAllFields - If true, all fields are exported, including those that have no value. If false (the default), excludes those fields that currently have no value.
bNoPassword - If true (the default), do not include text fields that have the password flag set in the exported FDF file.
aFields - The array of field names to submit or a string containing a single field name:
● If specified, only these fields are exported, except those excluded by
bNoPassword.
● If aFields is an empty array, no fields are exported. The FDF file might still
contain data, depending on the bAnnotations parameter.
● If this parameter is omitted or is null, all fields in the form are exported, except those excluded by bNoPassword.
bFlags - If true, field flags are included in the exported FDF file. The default is
false.
cPath - A string specifying the device-independent path for the file. The path may be relative to the location of the current document. If the parameter is omitted, a dialog box is shown to let the user select the file.
bAnnotations - If true, annotations are included in the exported FDF file.
The default is false.
Point five drives the whether privileged context is required (if included and privileged, the export can be executed silently). It is point six that will allow the annotations to be included in the FDF export.
Magic
I mentioned “magic” in the title of this post because that’s what it feels like when you set bAnnotations to true while exporting an FDF, then import the FDF to another PDF.
this.exportAsFDF({bAnnotations:true});All annotations and their properties are imported into the new PDF, and it happens in a split-second. The appearance, the page, the location on the page, and all other properties like author and read-only & print properties transfer to the new PDF. Of course the page number of the original annotation requires the second PDF to contain the same page number. This works for stamp annotations, whether the stamps are installed in the program of the importer or not.
All of the data is instantly written into the FDF for all the annotations to be instantly created on the new PDF with 100% accuracy. Amazing!
If you’re as curious as I was about what this data looks like, open the FDF by right-clicking the file and selecting Open with Notepad.



