4 Replies Latest reply on Dec 16, 2015 3:11 PM by Schmaltzkopf

    Does "documentPreferences" still work?

    Schmaltzkopf Level 1

      Hello There.

      I am trying the following script from the Adobe CS6 Scripting Tutorial:

       

       

      try{

          myFont = app.fonts.item("Arial");

      }

      catch (myError){};

      var myDocument = app.documents.item(0);

      with(myDocument){

          var myPage = pages.item(0);

          var myBounds = myGetBounds(myPage,myDocument);

          with(myDocument.pages.item(0)){

          //Get a reference to the text frame.

          var myTextFrame = textFrames.item(0);

          //Change the size of the text frame.

          myTextFrame.geometricBounds = myBounds;

          var myParagraph = myTextFrame.paragraphs.item(0);

          myParagraph.appliedFont = myFont;

          myParagraph.justification = Justification.centerAlign;

          myParagraph.pointSize = 48;

          }

      }

      //myGetBounds is a function that returns the bounds

      //of the "live area" of a page.

      function myGetBounds(myDocument, myPage){

      // line 28:

      var myPageWidth = myDocument.documentPreferences.pageWidth;

      var myPageHeight = myDocument.documentPreferences.pageHeight

      if(myPage.side == PageSideOptions.leftHand){

      var myX2 = myPage.marginPreferences.left;

      var myX1 = myPage.marginPreferences.right;

      }

      else{

      var myX1 = myPage.marginPreferences.left;

      var myX2 = myPage.marginPreferences.right;

      }

      var myY1 = myPage.marginPreferences.top;

      var myX2 = myPageWidth - myX2;

      var myY2 = myPageHeight - myPage.marginPreferences.bottom;

      return [myY1, myX1, myY2, myX2];

      }

       

      When I run it from the InDesign Scripts panel, I get the following:

      Capture.JPG

      Whats wrong?

       

      Any help would be greatly appreciated.