1 Reply Latest reply on Jan 10, 2017 6:43 AM by Peter Kahrel

    Release anchored objects on first page of doc

    jakec88782761 Level 2

      How do you release an anchored text frame from the first page of a doc?

       

      var textFrames =   app.activeDocument.textFrames.everyItem().getElements();

                              

                               for ( i; i<textFrames.length; i++ ) {

                                  

                                   if ( textFrames[i].parentPage===app.activeDocument.pages[0] && textFrames[i].anchoredObjectSettings.isValid) {

                                  

                                   textFrames[i].anchoredObjectSettings.releaseAnchoredObject();

                                   }

                               };

       

      This returns that resleaseAchoredObject is undefined..

        • 1. Re: Release anchored objects on first page of doc
          Peter Kahrel Adobe Community Professional & MVP

          You're after anchored frames, but you inspect app.activeDocument.textFrames.everyItem().getElements();, which does not return anchored frames. Instead you should e.g. get a handle of all page items. You can get them on page[0], no need to get them in the whole document (and you should probably go backwards too). A frame is anchored if its parent is a character.

           

           

          pItems = app.activeDocument.pages[0].allPageItems;
          for (i = pItems.length-1; i >= 0; i--) {
            if (pItems[i].parent instanceof Character && pItems[i].anchoredObjectSettings.anchoredPosition === AnchorPosition.ANCHORED) {
              pItems[i].anchoredObjectSettings.releaseAnchoredObject();
            }
          }
          

           

          textFrames[i].anchoredObjectSettings.isValid is not a useful test because every text frame has the property anchoredObjectSettings.

           

          Peter