Some test text!

How to save and load a custom property on an annotation?

You can extend the serialize and deserialize functions of Annotations.Annotation so that it adds a custom attribute to exported XFDF. For example:

// Save a reference to the old serialize function
var serialize = Annotations.Annotation.prototype.serialize;

Annotations.Annotation.prototype.serialize = function() {
  // call the old serialize function.
  // Returns an Element
  var el = serialize.apply(this, arguments);

  // Add our custom attribute to the element
  if (this.myCustomAttribute) {
    el.setAttribute('attribute-name', this.myCustomAttribute);

  // Make sure to return our new custom element
  return el;

// Save a reference to the old deserialize function
var deserialize = Annotations.Annotation.prototype.deserialize;

Annotations.Annotation.prototype.deserialize = function(el) {
  // call the old deserialze function
  deserialize.apply(this, arguments);

  // Apply the custom attribute to the Annotation
  this.myCustomAttribute = el.getAttribute('attribute-name');

Get the answers you need: Support