Annotation methods

destroy

getProps

getStateInModel

setProps

transitionToState

destroy

5.0

D 

 

C 

Destroys the annotation, removing it from the page. The object becomes invalid.

Example

Remove all "FreeText" annotations on page 0.

   var annots = this.getAnnots({ nPage:0 });

   for (var i = 0; i < annots.length; i++)

      if (annots[i].type == "FreeText") annots[i].destroy();

getProps

5.0

 

 

 

Get the collected properties of an annotation. Can be used to copy an annotation.

Returns

An object literal of the properties of the annotation. The object literal is just like the one passed to the Doc object addAnnot method.

Example 1

Copy a given annotation to every page in the document.

   var annot = this.addAnnot({

      page: 0,

      type: "Text",

      rect: [40, 40, 140, 140]

   });

   

   // Make a copy of the properties of annot

   var copy_props = annot.getProps();

   

   // Now create a new annot with the same properties on every page

   var numpages = this.numPages;

   for (var i=0; i < numpages; i++) {

      var copy_annot = this.addAnnot(copy_props);

      // but move it to page i

      copy_annot.page=i;

   }

Example 2

Display all properties and values of an annotation.

   var a = this.getAnnots(0);     // get all annots on page 0

   if ( a != null ) {

      var p = a[0].getProps();     // get the properties of first one

      for ( o in p ) console.println( o + " : " + p[o] );

   }

getStateInModel

6.0

 

 

 

Gets the current state of the annotation in the context of a state model. See also the transitionToState method.

Parameters

cStateModel 

The state model to determine the state of the annotation.

Returns

The result is an array of the identifiers for the current state of the annotation:

Example

Report on the status of all annotations on all pages of this document.

   annots = this.getAnnots()

   for ( var i= 0; i< annots.length; i++) {

      states = annots[i].getStateInModel("Review");

      if ( states.length > 0 ) {

         for(j = 0; j < states.length; j++)

         {

            var d = util.printd(2, states[j].modDate);

            var s = states[j].state;

            var a = states[j].author;

            

            console.println(annots[i].type + ": " + a + " "

               + s + " " + d + "on page "

               + (annots[i].page+1) );

         }

   

      }   

   }

setProps

5.0

D 

 

C 

Sets many properties of an annotation simultaneously.

Parameters

object literal

A generic object that specifies the properties of the Annotation object to be created (such as type, rect, and page). This object is the same as the parameter of the Doc object addAnnot method.

Returns

The Annotation object

Example

Set various properties of a Line annotation.

   var annot = this.addAnnot({type: "Line"})

   annot.setProps({

      page: 0,

      points: [[10,40],[200,200]],

      strokeColor: color.red,

      author: "A. C. Robat",

      contents: "Check with Jones on this point.",

      popupOpen: true,

      popupRect: [200, 100, 400, 200], // Place rect at tip of the arrow

      arrowBegin: "Diamond",

      arrowEnd: "OpenArrow"

   });

transitionToState

6.0

D 

 

C 

Sets the state of the annotation to cState by performing a state transition. The state transition is recorded in the audit trail of the annotation.

See also the getStateInModel method.

Note:For the states to work correctly in a multiuser environment, all users must have the same state model definitions. Therefore, it is best to place state model definitions in a folder-level JavaScript file that can be distributed to all users or installed on all systems.

Parameters

cStateModel 

The state model in which to perform the state transition. cStateModel must have been previously added by calling the Collab method addStateModel.

cState 

A valid state in the state model to transition to.

Example

Define a custom set of transition states, then set the state of an annotation.

   try {

      // Create a document

      var myDoc = app.newDoc();

      // Create an annot

      var myAnnot = myDoc.addAnnot

      ({

         page: 0,

         type: "Text",

         point: [300,400],

         name: "myAnnot",

      });

      // Create the state model

      var myStates = new Object();

      myStates["initial"] = {cUIName: "Haven't reviewed it"};

      myStates["approved"] = {cUIName: "I approve"};

      myStates["rejected"] = {cUIName: "Forget it"};

      myStates["resubmit"] = {cUIName: "Make some changes"};

      Collab.addStateModel({

         cName: "ReviewStates",

         cUIName: "My Review",

         oStates: myStates,

         cDefault: "initial"

      });

   } catch(e) { console.println(e); }

   // Change the states

   myAnnot.transitionToState("ReviewStates", "resubmit");

   myAnnot.transitionToState("ReviewStates", "approved");