Copy link to clipboard
Copied
I have a JavaScript script that opens a Letter size document containing one page, adds some text frames to the page, and then resizes them to fit their contents. Then I want to resize the page (or the document) down to the overall size of the text frames (approx. 5" wide and 3" high). I can accomplish what I want in InDesign by selecting the Page Tool, setting Liquid Page Rule to Off, and entering the width and height values. I cannot figure out how to do it in JavaScript. Help! Thanks!
2 Correct answers
Something like the following should work. This will resize the first page of the active document to new dimensions of 400*500 points
var doc = app.documents[0]
doc.pages[0].layoutRule = LayoutRuleOptions.OFF
var bb = BoundingBoxLimits.GEOMETRIC_PATH_BOUNDS
var a = AnchorPoint.TOP_LEFT_ANCHOR
var rm = ResizeMethods.REPLACING_CURRENT_DIMENSIONS_WITH
var nbb = [400, 500]
doc.pages[0].resize(bb, a, rm, nbb)
-Manan
Hi Dan,
test the script with pages of a facing-pages document and with ones from a non-facing-pages document.
You might see a difference in behavior, because in the case of a facing-pages document there is a spine where a page will be "glued" to when resized.
Regards,
Uwe Laubender
( ACP )
Copy link to clipboard
Copied
Something like the following should work. This will resize the first page of the active document to new dimensions of 400*500 points
var doc = app.documents[0]
doc.pages[0].layoutRule = LayoutRuleOptions.OFF
var bb = BoundingBoxLimits.GEOMETRIC_PATH_BOUNDS
var a = AnchorPoint.TOP_LEFT_ANCHOR
var rm = ResizeMethods.REPLACING_CURRENT_DIMENSIONS_WITH
var nbb = [400, 500]
doc.pages[0].resize(bb, a, rm, nbb)
-Manan
Copy link to clipboard
Copied
Hi Dan,
test the script with pages of a facing-pages document and with ones from a non-facing-pages document.
You might see a difference in behavior, because in the case of a facing-pages document there is a spine where a page will be "glued" to when resized.
Regards,
Uwe Laubender
( ACP )
Copy link to clipboard
Copied
I did both of your suggestions (page.resize as shown and non-facing-pages document) and got exactly what I wanted. Thanks very much for your help!

