Blog of Appliness
Automatic rescale with InDesign
![]()
In order to optimize our current workflow with Adobe Digital Publishing Suite and InDesign, we had to find a way to automatically handle two “renditions”: a 1536×2048 high-definition magazine for the new iPad, and a classic 768×1024 magazine for the classic tablets. With InDesign CS5.5, the manual operations are very painful. We have decided to start by designing the high-resolutions pages, and to scale down all the pages by 50% at the end of the process. So the team will work on “new iPad” layouts, and at the very end, generate the classic iPad 1 version. We’ve figured out that you can add scripts to InDesign… using JavaScript! As the magazine is edited by web developers, it has been very easy to understand the API and code a script to automate the scale down process.
The script…:
- gets the orientation of the document (landscape and portrait)
- unlock all the layers of the document
- loop on all the pages
- free the items from the master pages
- create a blank rectangle that fits the dimension of the page (to get a well defined center of the page while scaling)
- groups all the elements of the page
- scale everything by 50%
- resize the pages to 768×1024
- changes the properties of the document to set the new dimensions and the correct orientation
It will just generate a 1024×768 copy of your article that you can upload to DPS to target iPad1 and iPad2 devices. You’ll lose your layers, the master pages, etc… so you won’t be able to work properly on these files. Consider them as flat copies.
Here is the code:
var myScript = app.activeScript;
var myDocument = app.activeDocument;
// GET current page orientation
var currentOrientation = myDocument.documentPreferences.pageOrientation;
//UNLOCK LAYERS
var myLayers = myDocument.layers.itemByRange(0, myDocument.layers.length-1);
myLayers.locked = false;
//LOOP on all pages
var myPages = myDocument.pages;
for (var i=0; i< myPages.length; i++){
//Free the items from the master
var allItems = myDocument.pages[i].appliedMaster.pageItems.everyItem().getElements();
for(var j=0;j < allItems.length;j++){
try{allItems[i].override(myDocument.pages[i])}
catch(e){}
}
//Create a blank rectangle that fits the dimension of my page
myPages.item(i).rectangles.add({geometricBounds:[0,0, myDocument.documentPreferences.pageHeight, myDocument.documentPreferences.pageWidth]});
// Group all items in first page
myPages.item(i).groups.add(myPages.item(i).pageItems);
//Scale 50%
var myScaleMatrix = app.transformationMatrices.add({horizontalScaleFactor:.5, verticalScaleFactor:.5});
myPages.item(i).groups.item(0).transform(CoordinateSpaces.pasteboardCoordinates, AnchorPoint.centerAnchor, myScaleMatrix);
//Resize Page
myPages.item(i).resize(CoordinateSpaces.INNER_COORDINATES,AnchorPoint.CENTER_ANCHOR,ResizeMethods.MULTIPLYING_CURRENT_DIMENSIONS_BY,[.5, .5]);
//unGroup page
myPages.item(i).groups.item(0).ungroup(); }
alert("Resize all pages -- done");
myDocument.documentPreferences.pageWidth = 768;
myDocument.documentPreferences.pageHeight = 1024;
myDocument.documentPreferences.pageOrientation = currentOrientation;
Comments
Powered by Facebook Comments




4 Comments
john f.x. clarke jr.
April 10, 2012very clever. i am caught in a similar situation, needing to find a developer in nyc. might you recommend someone?
Michaël Chaize
April 11, 2012Thanks. You should write a post on forums.adobe.com. There is a dedicated forum for DPS.
Ivan
May 23, 2012You actually do not need to create a separate set of files for the two renditions. You simply need to upload the 1536 x 2048 layouts into both a 2048 x 1536 and a 1024 x 768 folio. The act of adding your 2048 x 1536 layouts to the iPad 1/2 folio will actually re-size and re-sample the files.
Michaël Chaize
June 5, 2012yes indeed, that’s what we are doing now. And with InDesign CS6, you have it automatically (new alternative layout > rescale)