Copy link to clipboard
Copied
I have multiple InDesign files that I use to create a brandmarks. Each brandmark is different size. I need help with a script that will change the page size to the items on the page, save, close and move on to the next document. Any help out there is appreciated.
Copy link to clipboard
Copied
Any help out there is appreciated.
Hi @jasons5017064 , You would have to use the resize method, in order to resize a page to its contents. A simple example would be something like this where I’m resizing page 1 to its page items. I’m grouping the page items to get their combined width and height, which might be a problem if you are depending on multiple document layers:
//use points for page resize
app.scriptPreferences.measurementUnit = MeasurementUnits.POINTS;
var d = app.activeDocument;
d.zeroPoint = [0, 0];
var p = d.pages[0]
var api = p.pageItems;
var tg;
if (api.length == 1) {
tg = api[0]
} else {
//group page items to get bounds—moves everything to top layer, is that OK?
tg = d.groups.add(api);
}
//get the group’s width and height
var b = tg.geometricBounds;
var h = b[2] - b[0]
var w = b[3] - b[1]
//resize the page
p.resize (CoordinateSpaces.INNER_COORDINATES,AnchorPoint.CENTER_ANCHOR,ResizeMethods.REPLACING_CURRENT_DIMENSIONS_WITH,[w,h])
tg.move([0,0])
app.scriptPreferences.measurementUnit = AutoEnum.AUTO_VALUE;
Before and after: