Class AnnotationMapper


  • public final class AnnotationMapper
    extends java.lang.Object
    Maps one PDF annotation dictionary to and from its XfdfAnnotation form (ISO 19444-1 §6.4), covering every markup annotation subtype XFDF has an element for: Text, Link, FreeText, Line, Square, Circle, Polygon, PolyLine, Highlight, Underline, Squiggly, StrikeOut, Stamp, Caret, Ink, Popup, FileAttachment, Sound and Redact. Widget is deliberately excluded -- form field annotations carry their value through <fields> instead (see FieldMapper), never through <annots>.

    Not round-tripped (documented v1 scope boundaries, each because XFDF itself has no clean syntax for it or because implementing it well is a project of its own): a Link's /A navigation action (its <OnActivation> target is read on import for informational purposes only and never re-derived on export); a FreeText/Line's leader-line geometry (/LL//LLE//LLO); a Stamp's custom appearance bitmap (<imagedata>); and a FileAttachment/Sound's actual embedded bytes (only the file-specification metadata round-trips, not the data itself). None of these omissions corrupt anything they touch -- the annotation itself still imports/exports correctly, just without that one extra piece of unusual data.

    • Method Detail

      • isSupportedSubtype

        public static boolean isSupportedSubtype​(java.lang.String subtype)
        true if subtype (a PDF /Subtype name) has an XFDF representation this mapper handles.
      • applyToCOS

        public static void applyToCOS​(XfdfAnnotation x,
                                      COSDictionary target,
                                      COSDocument targetDoc)
        Populates (or, for an already-populated target passed in by the caller's "update if exists" handling -- see XfdfImporter -- re-populates) target from x. target is expected to already be registered as an indirect object of targetDoc (its /P, /NM identity and page membership are the caller's responsibility; this only fills in the annotation's own visual/content properties).