Copy link to clipboard
Copied
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.
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
...
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
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:
After running last JS script—Document Setup and Page dimensions match:
Adding 6 pages with no master Print Booklet works:
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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:
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Can you sahre the document that you created with added pages that will not print?
Copy link to clipboard
Copied
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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!
Copy link to clipboard
Copied
Like I've said - I was replying from my phone 😞
In this case you need to calculate width & height from GeometricBounds.
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
Right 😞
Bounds instead of GeometricBounds 😞
Copy link to clipboard
Copied
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:
It reports the page sizes as the same in the MsgBox, but it seems to fail when it compares them.
Copy link to clipboard
Copied
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")
Copy link to clipboard
Copied
Could it be a Windows-specific bug?
Copy link to clipboard
Copied
Did you try resetting your prefs and caches—corrupted Caches can cause UI problems? You could also try saving an IDML and reopening.
Copy link to clipboard
Copied
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!
Copy link to clipboard
Copied
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?:
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Hi @chrisnaylor , Have you tried clearing your caches and preferences?
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Many thanks for your posting - I take your point!
Copy link to clipboard
Copied
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 )
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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 )
Find more inspiration, events, and resources on the new Adobe Community
Explore Now