0 Replies Latest reply on Mar 10, 2009 12:33 AM by (Stefan_Huwiler)

    [JS, CS3]  Setting Page Destination on Button

    Level 1

      I unsuccessfull try to set the a Page Destination on a Button.
      The script loops through the Document and picks certain textframes, which contain the page.name as text. inside the loop I do this:

      // START LOOP

      // Getting the Content of Textframe -> this is the destination Page Number
      myDestinationPage = myDocument.pages.itemByName ( myDocument.pages[ pageIterator ].textFrames[ textFrameIterator ].contents );

      // Creating a HyperlinkPageDestinationObject
      myHyperlinkPageDestination = myDocument.hyperlinkPageDestinations.add( myDestinationPage );

      // Creating a new Button over a certain area on the actual Page - setting visibility off
      myButton = myDocument.pages[ pageIterator ].buttons.add({visibilityInPdf:1181247844, geometricBounds:[ myDocument.pages[ pageIterator ].textFrames[ textFrameIterator ].geometricBounds[ 0 ],12,myDocument.pages[ pageIterator ].textFrames[ textFrameIterator ].geometricBounds[ 2 ], myDocument.pages[ pageIterator ].textFrames[ textFrameIterator ].geometricBounds[ 3 ]]});

      // Creating an hyperlinkPageItemSource = the Actual Button myHyperlinkPageItemSource = myDocument.hyperlinkPageItemSources.add( myButton );

      // Creating an Hyperlink
      myHyperlink = myDocument.hyperlinks.add( myHyperlinkPageItemSource, myHyperlinkPageDestination );

      //The Destination shall be a Ceratin Page so I add a gotoAnchorBehavior
      myGotoAnchorBehavior = myButton.gotoAnchorBehaviors.add();

      // Now I try to set the Anchor Target. I think that's not working...
      myGotoAnchorBehavior.anchorItem =myHyperlink;

      // END LOOP

      The Buttons are there, the Destinations as well, but the ceratin button has not the desired Page as destination. Does someone have a hint on this topic?

      Thanks and greets