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

Resize page by script

Explorer ,
Mar 02, 2022 Mar 02, 2022

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!

TOPICS
Scripting
1.9K
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 2 Correct answers

Community Expert , Mar 02, 2022 Mar 02, 2022

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

Translate
Community Expert , Mar 03, 2022 Mar 03, 2022

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 )

Translate
Community Expert ,
Mar 02, 2022 Mar 02, 2022

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

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 ,
Mar 03, 2022 Mar 03, 2022

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 )

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 ,
Mar 03, 2022 Mar 03, 2022
LATEST

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!

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