Skip to main content
Inspiring
December 16, 2015
Answered

Does "documentPreferences" still work?

  • December 16, 2015
  • 1 reply
  • 709 views

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:

Whats wrong?

Any help would be greatly appreciated.

This topic has been closed for replies.
Correct answer Ronald63

Hi,

You have reversed arguments when you call the function myGetBounds


var myBounds = myGetBounds(myPage,myDocument);

function myGetBounds(myDocument, myPage)

Regards

1 reply

Ronald63Correct answer
Legend
December 16, 2015

Hi,

You have reversed arguments when you call the function myGetBounds


var myBounds = myGetBounds(myPage,myDocument);

function myGetBounds(myDocument, myPage)

Regards

Inspiring
December 16, 2015

I realized that. The script is copied-and-pasted from the "Adobe CS6 Scripting Tutorial" PDF. I tried reversing the arguments and when I ran the script from the ID script panel nothing happened (there was no indicationat all that it ran the script)

Harbs.
Legend
December 16, 2015

Well, did the frame fit the page dimensions?