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

[JS CS5]How to get Custom Page size

Contributor ,
May 18, 2011 May 18, 2011

I've been searching the answer of this simple question but looking no way around.

I have an InDesign document with different page size e.g. left page width is 621 pt. and on the same document right page width is 837 pt.

Now I need to get the width of pages using script but app.documentPreferences.pageWidth return standard document preset size(621 pt.) not the custom page size.

Does any one have the Idea to get custom page size using script.

Thanks in advance

Mac

TOPICS
Scripting
4.0K
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

Community Expert , May 18, 2011 May 18, 2011

Mac,

as documentation is showing there are some new properties of "page" since InDesign CS5.
Among those is:

bounds    Array of Measurement Unit (Number or String)    readonly    The bounds of the Page, in the format [y1, x1, y2, x2].

So:

myPage.bounds

and pageWidth of the documentPreferences might be:

myPage.bounds[3]-myPage.bounds[1]

unless  myPage is transformed (e.g. rotated and/or sheared and/or scaled) with:

myPage.transform()

void transform (in: CoordinateSpaces, from: varies, withMatrix: varies[,
...
Translate
Community Expert ,
May 18, 2011 May 18, 2011

Mac,

as documentation is showing there are some new properties of "page" since InDesign CS5.
Among those is:

bounds    Array of Measurement Unit (Number or String)    readonly    The bounds of the Page, in the format [y1, x1, y2, x2].

So:

myPage.bounds

and pageWidth of the documentPreferences might be:

myPage.bounds[3]-myPage.bounds[1]

unless  myPage is transformed (e.g. rotated and/or sheared and/or scaled) with:

myPage.transform()

void transform (in: CoordinateSpaces, from: varies, withMatrix: varies[, replacingCurrent: varies][, consideringRulerUnits: bool=false])
Transform the page item.

var d = app.activeDocument;
var myPage = d.pages[0];


var oldPB = myPage.bounds;

var rAngle = -45;
var sAngle = 40;

var myTransformationMatrix1 = app.transformationMatrices.add({counterclockwiseRotationAngle:rAngle});

myPage.transform(CoordinateSpaces.INNER_COORDINATES, AnchorPoint.CENTER_ANCHOR, myTransformationMatrix1);

var myTransformationMatrix2 = app.transformationMatrices.add({clockwiseShearAngle:sAngle});
myPage.transform(CoordinateSpaces.INNER_COORDINATES, AnchorPoint.CENTER_ANCHOR, myTransformationMatrix2);

var newPB = myPage.bounds;

$.writeln(oldPB);
$.writeln(newPB);

Now oldPB and newPB will differ a lot.
So, the question remains: what is a reliable way to show if the myPage was or was not transformed against documentPreferences.pageWidth or if  myPage is of rectangular shape at all. See the possibility of adding a sheer angle to the transformation matrix. Also see screen shot:

Transform_Page_CS5.png

Uwe

Transform_Page_CS5.png

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 ,
May 18, 2011 May 18, 2011

Uwe wrote:

So, the question remains: what is a reliable way to show if the myPage was or was not transformed against documentPreferences.pageWidth or if  myPage is of rectangular shape at all. See the possibility of adding a sheer angle to the transformation matrix.

Is this not Page.transformValuesOf()?

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
Community Expert ,
May 18, 2011 May 18, 2011

John,

sure, thank you for pointing this out.

Furthermore I recommend reading "indesigncs3_transform_tutorial_javascript.pdf".
Also as a hint to myself 😉

Uwe

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 ,
May 18, 2011 May 18, 2011
Furthermore I recommend reading "indesigncs3_transform_tutorial_javascript.pdf".

In case it wasn't obvious, that's linked from http://www.adobe.com/products/indesign/extend.displayTab2.html#content-dotcom-en-products-indesign-e...

and available at
http://wwwimages.adobe.com/www.adobe.com/content/dam/Adobe/en/products/indesign/pdfs/indesigncs3_tra...

along with some sample scripts at the first URL.

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
Contributor ,
May 18, 2011 May 18, 2011
LATEST

Absolutly correct myPage.bounds is what I was looking for.

Many Thanks to Both John and Uwe for great help.

Mac

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