Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Does "documentPreferences" still work?

Explorer ,
Dec 15, 2015 Dec 15, 2015

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.

TOPICS
Scripting
762
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Enthusiast , Dec 15, 2015 Dec 15, 2015

Hi,

You have reversed arguments when you call the function myGetBounds


var myBounds = myGetBounds(myPage,myDocument);

function myGetBounds(myDocument, myPage)

Regards

Translate
Enthusiast ,
Dec 15, 2015 Dec 15, 2015

Hi,

You have reversed arguments when you call the function myGetBounds


var myBounds = myGetBounds(myPage,myDocument);

function myGetBounds(myDocument, myPage)

Regards

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Dec 16, 2015 Dec 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)

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 16, 2015 Dec 16, 2015

Well, did the frame fit the page dimensions?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Dec 16, 2015 Dec 16, 2015
LATEST

Yes.Thank you for your help.

Note to all: "Adobe CS6 Scripting Tutorial" PDF has at least one error in their script. See the first post in this thread.


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines