Skip to main content
Known Participant
November 24, 2022
Answered

InDesign Script to set Masterspread page sizes

  • November 24, 2022
  • 3 replies
  • 6177 views

Does anyone have any ideas for an InDesign Script to set Masterspread page sizes?

 

I have been trying to change the page sizes in a Masterspread using VBScript but with no sucess and can't find any reference for it.

 

I thought it would probably be something in MasterSpread.Preferences but I've tried several variations of

PageWidth, PageHeight, Width, Height etc 

eg

 

myDocument.MasterSpread.Preferences.PageWidth=120

myDocument.MasterSpread.Preferences.Width=120

myDocument.MasterSpread.PageWidth=120

myDocument.MasterSpread.Width=120

myDocument.MasterSpread.Page(0).Preferences.PageWidth=120

myDocument.MasterSpread.Page(0).Preferences.Width=120

 

but with no success.

Any suggestions would be gratefully appreciated.

This topic has been closed for replies.
Correct answer rob day

Hi @chrisnaylor , try the resize() method. This is JS

 

 

 

//6"x9" page. By default the resize() method expects points
var w = 432
var h = 648

//the document‘s first masterSpread
var myLP=app.activeDocument.masterSpreads[0].pages[0];
var myRP=app.activeDocument.masterSpreads[0].pages[1];

myLP.resize (CoordinateSpaces.INNER_COORDINATES,AnchorPoint.CENTER_ANCHOR,ResizeMethods.REPLACING_CURRENT_DIMENSIONS_WITH,[w,h])
myRP.resize (CoordinateSpaces.INNER_COORDINATES,AnchorPoint.CENTER_ANCHOR,ResizeMethods.REPLACING_CURRENT_DIMENSIONS_WITH,[w,h])

 

 

3 replies

Community Expert
January 17, 2023

Hi @chrisnaylor ,

downloaded your sample InDesign document Blank Pages (506 x 791).indd, added 2 pages through the Pages panel and was able to use Print Booklet without any errors. German InDesign CS6 version 8.1.0.420 on Windows 10.

 

Printed to PostScript with the Adobe PDF 9.0 PPD file, file name ADPDF9.PPD, that I installed at

Adobe InDesign CS6 > Presets > PPDs in the Application folder on my C drive.

 

What's your eaxct version of InDesign CS6 ?

 

Regards,
Uwe Laubender
( Adobe Community Expert )

Known Participant
January 17, 2023

Many thanks for your posting and your interest in the problem.

 

Did you resize the document before adding the extra pages and attempting Print Booklet?

 

There doesn't appear to be a problem if you simply use Print Booklet witbout any prior resizing.

 

I'm using Adobe InDeign CS6 8.0. according to About InDesign, under Windows 10 Pro 64 bit.

Community Expert
January 17, 2023

Hi @chrisnaylor ,

now I did a second test:

[1] Changed the rulers to Points

[2] Ran Rob's script on the document ( the one posted as "Correct" )

[3] Added 6 pages to the document through the Pages panel

 

Printed to PostScript with Print Booklet.

I had an issue with page 1. The page did not show the page number from the applied master spread.

Solved this by applying master [None] and again A Master. Here I got a message that the page is in a different format, but that was no real issue, because I decided to change the page size according to the applied master:

 

 

Still page 1 had no page number.

I removed page 1 and added a new page before my first page in the document.

Now all went OK and I was able to use Print Booklet as intended:

 

 

Applied the document, the PostScript file and the distilled PDF.

 

Regards,
Uwe Laubender
( Adobe Community Expert )

 

Robert at ID-Tasker
Legend
November 24, 2022

In VB indexes of the elements start from 1 - not 0 - so .Pages(1) - can't check the overall validity of the code right now but you've already received JS solution from @rob day

 

Known Participant
November 25, 2022

Many thanks for your posting - I take your point!

rob day
Community Expert
rob dayCommunity ExpertCorrect answer
Community Expert
November 24, 2022

Hi @chrisnaylor , try the resize() method. This is JS

 

 

 

//6"x9" page. By default the resize() method expects points
var w = 432
var h = 648

//the document‘s first masterSpread
var myLP=app.activeDocument.masterSpreads[0].pages[0];
var myRP=app.activeDocument.masterSpreads[0].pages[1];

myLP.resize (CoordinateSpaces.INNER_COORDINATES,AnchorPoint.CENTER_ANCHOR,ResizeMethods.REPLACING_CURRENT_DIMENSIONS_WITH,[w,h])
myRP.resize (CoordinateSpaces.INNER_COORDINATES,AnchorPoint.CENTER_ANCHOR,ResizeMethods.REPLACING_CURRENT_DIMENSIONS_WITH,[w,h])

 

 

Known Participant
November 25, 2022

Many thanks for your posting - that was very helpful!

 

I have converted your sugegstion into VBScript and it seems to work well, as follows:

 

myArray = Array(mypageWidth,mypageHeight)
myDocument.MasterSpreads(1).Pages(1).Resize idCoordinateSpaces.idInnerCoordinates, idAnchorPoint.idCenterAnchor,idResizeMethods.idReplacingCurrentDimensionsWith, myArray

myDocument.MasterSpreads(1).Pages(2).Resize idCoordinateSpaces.idInnerCoordinates, idAnchorPoint.idCenterAnchor,idResizeMethods.idReplacingCurrentDimensionsWith, myArray

 

The only snag I'm hitting is that the measurments seem to assume points - and I'm having difficulty working out how to get it to use millimeters.

 

I have tried various approaches, such as :

 

myInDesign.ScriptPreferences.MeasurementUnit = idMeasurementUnits.idmillimeters

and

myDocument.MasterSpreads.Item(1).HorizontalMeasurementUnits = idMeasurementUnits.idmillimeters

 

But none of them seem to work.

 

Any suggestions would be gratefully appreciated.

Robert at ID-Tasker
Legend
November 25, 2022