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

InDesign Script to set Masterspread page sizes

Explorer ,
Nov 24, 2022 Nov 24, 2022

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.

TOPICS
Scripting
5.7K
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 , Nov 24, 2022 Nov 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,Resiz
...
Translate
Explorer ,
Nov 30, 2022 Nov 30, 2022

Many thanks for the suggestion - in fact, I had already given DocumentPreferences a try, with:

 

myDocument.DocumentPreferences.pageWidth=mypageWidth
myDocument.DocumentPreferences.pageHeight=mypageHeight

 

together with:

 

myDocument.ViewPreferences.HorizontalMeasurementUnits=idMeasurementUnits.idmillimeters
myDocument.ViewPreferences.VerticalMeasurementUnits=idMeasurementUnits.idmillimeters

 

I had also started to wonder if the Presets might have something to do with it, so tried:

 

For i=1 to myInDesign.DocumentPresets.Count
myInDesign.DocumentPresets.Item(i).pageWidth=mypageWidth
myInDesign.DocumentPresets.Item(i).pageHeight=mypageHeight
Next

 

But, again, to no avail.

 

I have tried running your js script both before and after adding a nrw page to the template file I provided, but it still doesn't work with Print Booklet if the document is resized before the new page is added.

 

Does it work on your system?

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 ,
Nov 30, 2022 Nov 30, 2022

still doesn't work with Print Booklet if the document is resized before the new page is added.

 

It works for me. I added the code to change the Document Setup in case the added pages had no Parent—[None]—you would need both the documentPreference and the resize.

 

Your template:

 

Screen Shot 1.png

 

After running last JS script—Document Setup and Page dimensions match:

Screen Shot 2.png

 

Adding 6 pages with no master Print Booklet works:

 

Screen Shot 3.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
Explorer ,
Dec 02, 2022 Dec 02, 2022

Many thanks for your posting and continued interest in this matter.

 

As a check, I tried creating a new blank document entirely, with File...New, resizing it using your js code; then adding pages and tried to use Print Booklet - but still got the same error.

 

I think it must be a bug in InDesign.

 

I am using CS6 and found these posts:

 

Print Booklet won't let me because of multiple pag... - Adobe Support Community - 3279570

Solved: Error when printing booklet - Adobe Support Community - 4476115

 

This looks like the cause of the problem, to me.

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 ,
Dec 02, 2022 Dec 02, 2022

I just checked the javascript with CS6 on OSX Mojave, and it worked for me when I ran it on your 2 page template and then added 6 pages. Here I’m Saving a Postscript file using the Adobe PDF 9.0 PPD:

 

Screen Shot 7.pngScreen Shot 8.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
Explorer ,
Dec 02, 2022 Dec 02, 2022

Many thanks for your posting - I appreciate the effort you are putting into this!

 

I note that you have tested CS6 under Apple OSX.

 

I have been running CS6 under Windows 10 Pro 64 bit.

 

In case it was an installation problem, I have just run it on Windows 7 Pro 64 bit - and got exactly the same problem.

 

Could it be a bug specific to the Windows version?

 

The references I quoted don't seem to state which OS they were using.

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 ,
Dec 02, 2022 Dec 02, 2022

Can you sahre the document that you created with added pages that will not print?

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 02, 2022 Dec 02, 2022

This file consists of two blank pages.

 

I have included some screen shots.

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 02, 2022 Dec 02, 2022

Looks like you need to compare sizes of the pages. 

 

I'm replying from my phone but I'll try:

 

Set myindi = createobject("InDesign.application")

Set myDoc = myindi.activedocument

For a=2 to myDoc.pages.count

If myDoc.pages.item(a-1).pagewith<>myDoc.pages.item(a).pagewith Or myDoc.pages.item(a-1).pageheight<>myDoc.pages.item(a).pageheight then

Call msgbox("pages " & (a-1) & " " & a & " are different" ) 

End if

Next a

 

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 05, 2022 Dec 05, 2022

Many thanks for your posting - it looks like a helpful idea, but I've had difficulty getting it to accept

 

myDocument.pages.item(a-1).pagewidth

 

Unless I've missed something (which wouldn't surprise me) Pagewidth has to be accessed via:

 

myInDesign.DocumentPreset.pageWidth

or
myDocument.DocumentPreferences.pageWidth

 

and these seem to apply at the document level.

 

But I must have missed something here, otherwise no document could have unequal page sizes at all!

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 05, 2022 Dec 05, 2022

Like I've said - I was replying from my phone 😞

 

In this case you need to calculate width & height from GeometricBounds.

 

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 ,
Dec 05, 2022 Dec 05, 2022

But I must have missed something here, otherwise no document could have unequal page sizes at all!

 

The page object has a .bounds property which wouldn’t necessarily match the .documentPreferences. In JS this gets each page’s width and height:

 

 

 

var p = app.activeDocument.pages;
var b, w, h;
for (var i = 0; i < p.length; i++){
    b = p[i].bounds;
    w = b[3]-b[1]
    h = b[2]-b[0]
    $.writeln(w + " x " +h)
}

 

 

https://www.indesignjs.de/extendscriptAPI/indesign-latest/#Page.html

 

The problem seems to be specific to your InDesign install. Did you try clearing your caches and prefs?

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 05, 2022 Dec 05, 2022

Right 😞

 

Bounds instead of GeometricBounds 😞

 

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 05, 2022 Dec 05, 2022

Many thanks for your postings.

 

I have tried the following VBScript code:

 

'Check for unequal page sizes:

For a=2 to myDocument.pages.count
mySizeArray1=myDocument.pages(a-1).bounds
mySizeArray2=myDocument.pages(a).bounds
myPageWidth1=mySizeArray1(3)-mySizeArray1(1)
myPageWidth2=mySizeArray2(3)-mySizeArray2(1)
myPageHeight1=mySizeArray1(2)-mySizeArray1(0)
myPageHeight2=mySizeArray2(2)-mySizeArray2(0)
MsgBox "myDocument.pages = " & mypageWidth1 & " x " & mypageHeight1 & vbCR & mypageWidth2 & " x " & mypageHeight2 , ,MessageTitle
If (mypagewidth1<>mypagewidth2) Or (mypageheight1<>mypageheight2) then
Msgbox "pages " & (a-1) & " " & a & " are different" & vbCR & "myDocument.pages = " & mypageWidth1 & " x " & mypageHeight1 & vbCR & mypageWidth2 & " x " & mypageHeight2 , ,MessageTitle
else
Msgbox "page sizes ok"
End if
Next

 

But I got a very strange result:

 

Unequal Page sizes.jpg

 

It reports the page sizes as the same in the MsgBox, but it seems to fail when it compares them.

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 ,
Dec 05, 2022 Dec 05, 2022

I don’t think you need to extract the width and height, just compare the bounds array. This tells me the page bounds match

var p = app.activeDocument.pages;
for (var i = 0; i < p.length; i++){
    if (p[i].bounds.toString() != p[0].bounds.toString()) {
        alert("Document Pages Don’t Match")
        exit();
    } 
}
alert("Document Pages Match")

 

Screen Shot 20.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
Explorer ,
Dec 05, 2022 Dec 05, 2022

Could it be a Windows-specific bug?

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 ,
Dec 05, 2022 Dec 05, 2022

Did you try resetting your prefs and caches—corrupted Caches can cause UI problems? You could also try saving an IDML and reopening.

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 06, 2022 Dec 06, 2022

Many thanks for your postings and suggestions.

 

I have tried resetting preferences and caches by deleting the files:

 

InDesign Defaults

InDesign SavedData

 

I also saved the blank pages document as an IDML file and reopened it, to see if that helped.

 

Unfortunately, none of these worked - with Print Booklet still failing with mutiple page size error.

 

I have also tried opening the IDML file under InDesign CS5 and that, too, showed the same error.

 

In the light of the posting I referenced earlier at Print Booklet won't let me because of multiple pag... - Adobe Support Community - 3279570 my best guess at the moment is a Windows-specific bug in CS5 and CS6.

 

But I'm definitely open to suggestions!

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 ,
Dec 02, 2022 Dec 02, 2022

Prints fine for me out of CS6 and CC2021. Here is my Print Settings..., have you tried a PostScript File using Adobe PDF 9.0?:

 

Screen Shot 10.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
Explorer ,
Dec 05, 2022 Dec 05, 2022

Many thanks for your posting.

 

I have tried printing to Adobe pdf and, also, to other printers in case it was a driver problem - but with no success.

 

 

Print to PDF-1.jpgPrint to PDF-2.jpg

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

Hi @chrisnaylor , Have you tried clearing your caches and preferences?

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 ,
Nov 24, 2022 Nov 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

 

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 ,
Nov 25, 2022 Nov 25, 2022

Many thanks for your posting - I take your point!

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 ,
Jan 17, 2023 Jan 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 )

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 ,
Jan 17, 2023 Jan 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.

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 ,
Jan 17, 2023 Jan 17, 2023
LATEST

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:

 

Message-PageSizesAreDifferent.PNG

 

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:

 

PrintBooklet-1.PNG

 

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

 

Regards,
Uwe Laubender
( Adobe Community Expert )

 

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