2 Replies Latest reply on Apr 30, 2010 6:16 AM by mrinmoy1984

    How to convert textframe to button

    mrinmoy1984

      How to convert textframe to button?

        • 1. Re: How to convert textframe to button
          Marc Autret Level 4

          I didn't find a 'clean' way to do this through the DOM. As a workaround you can emulate a "Convert to button" action, provided your script is allowed to select the textframe target:

           

          // convertToButton for ID CS4
          
          function convertToButton(/*PageItem*/obj, /*str*/bName, /*str*/bDesc)
          {
               app.selection = [obj];
               var maCreateButton = app.menuActions.item('$ID/$$$/Dialog/CmdName/CreateButton'),
                    ret;
          
               if( !maCreateButton.isValid ) return false;
               maCreateButton.invoke();
               ret = app.selection[0];
                    
               ret.name = bName||ret.name;
               ret.description = bDesc||ret.description;
                    
               return ret;
          };
          
          // sample code
          var myTextFrame = app.activeDocument.textFrames[0];
          var myButton = convertToButton(myTextFrame);
          

           

          Note: this approach is used in FlyingButtons:

          http://www.indiscripts.com/post/2010/03/flyingbuttons-a-script-to-automate-pdf-portfolios

           

           

          @+

          Marc

          1 person found this helpful
          • 2. Re: How to convert textframe to button
            mrinmoy1984 Level 1

            Thanks mark,

            It's working. I've also tried to do it from DOM. But failed to find appropriate method. Thanks again!!!!