7 Replies Latest reply on Dec 8, 2010 1:09 PM by dying veteran

    Creating Annotations

    Techi Panda Level 2

      Hi experts

       

      I want to change the default property of annotation before i inserting annotation

       

      i tried this but i am failed

       

      this.Annot.setProps({strokeColor:color.blue});

       

      I dont want to use this.addAnnot() function i want to change the default properties for all type of annotations.

       

      how to do this?

       

      thanks in advance

       

      regards

      a r u l

        • 1. Re: Creating Annotations
          try67 MVP & Adobe Community Professional

          You need to use this.getAnnots() and then loop over the array that it return

          in order to change the property of each annotation.

          • 2. Re: Creating Annotations
            RainbowChunChunChang Level 1

            Any sample code for looping over the array ?

             

            How to obtain the number of elements in the array ? by dot length ?

             

            Thanks,

            Rainbow

            • 3. Re: Creating Annotations
              try67 MVP & Adobe Community Professional

              var annots = this.getAnnots();

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

                   annots[i].setProps({strokeColor:color.blue});

              }

              • 4. Re: Creating Annotations
                Techi Panda Level 2

                Hi try67 thanks a lot for your reply it helps

                 

                the script works with annotations already created in the document

                 

                my scope is creating annotations with three different colors red, blue, yellow.  I have defined meaning for colors

                 

                1. Annotations with Yellow color is normal instruction

                2. Annotations with Blue color is medium instructin

                3. Annotations with Red is serious instruction

                 

                While i am creating annotations every time i have to go and change the properties. So that i have designed three buttons Red, Blue and Yellow before I insert annotation I press Red button for Red annotations and Press Blue button for Blue annotations. This is what I am trying so that i am trying to change the annotation properties before inserting

                 

                i hope i am clear little bit now

                 

                a r u l

                • 5. Re: Creating Annotations
                  try67 MVP & Adobe Community Professional

                  You can only do that if you insert the annotations with a script, using the

                  addAnnot command.

                  • 6. Re: Creating Annotations
                    Techi Panda Level 2

                    thank you try67 I can understand that i cant make it before inserting and finally i have changed the way and i am done here now i want to show the button always while open acrobat

                     

                    here is my work

                     

                    app.addToolButton({
                    cName: "Blue",
                    cExec: "Cblue();",
                    cTooltext: "My toolbar button 1",
                    nPos: 0
                    });
                    function  Cblue()
                    {
                    this.syncAnnotScan();
                    var myAnnotList = this.getAnnots({
                    nSortBy: ANSB_ModDate,
                    });
                    for (i=0; i<myAnnotList.length; i++) {
                    if([i]==0)
                    {
                         myAnnotList[i].setProps({strokeColor:color.blue});
                    }
                    }
                    }
                    regards
                    a r u l

                    • 7. Re: Creating Annotations
                      dying veteran Level 1

                      Your code is very unreadable to help due to poor indentation and no comments which you should put. Here I do cleanup for you :

                       

                      //
                      app.addToolButton({
                            cName: "Blue",
                            cExec: "Cblue();",
                            cTooltext: "My toolbar button 1",
                            nPos: 0
                          });
                      //
                      function  Cblue()
                      {
                        this.syncAnnotScan(); //
                        var myAnnotList = this.getAnnots({
                               nSortBy: ANSB_ModDate,
                             });
                        for (i=0; i<myAnnotList.length; i++) {
                          if([i]==0){
                            myAnnotList[i].setProps({strokeColor:color.blue}); //
                          }
                        }
                      }