Skip to main content
Participant
October 31, 2023
Question

Indesign script to resize all image frames in a document

  • October 31, 2023
  • 2 replies
  • 1687 views

Hello all,

 

I have a document of around 800 pages that is been made by importing PDF pages.

Unfortunately, the document has been set up in the wrong format (A4 instead of Letter size), so I have changed the document dimensions using Adjust Layout and the used this script to fit the content of the image into the newly adjusted frame:

 

app.activeDocument.rectangles.everyItem().fit(FitOptions.CONTENT_TO_FRAME);

 

The problem I am experiecing is that each PDF has a border aroud it which I would like to cut, so I would now like to resize the frame of a couple mm to cut the border. Is there a script I can use to achieve that?
Happy to run one script to do all of it (resizing and cutting) or to run two separate ones.

Thank you!

This topic has been closed for replies.

2 replies

rob day
Community Expert
Community Expert
October 31, 2023

Hi @Francesco23262834dw7e , Try this:

 

var v = 2;//the amount in points to crop
app.scriptPreferences.measurementUnit = MeasurementUnits.POINTS;
var lnks = app.activeDocument.links.everyItem().getElements();
var f, b;
for (var i = 0; i < lnks.length; i++){
    f= lnks[i].parent.parent;
    f.fit(FitOptions.FRAME_TO_CONTENT) 
    b = f.geometricBounds;
    f.geometricBounds = [b[0]+v, b[1]+v, b[2]-v, b[3]-v];
};   
app.scriptPreferences.measurementUnit = AutoEnum.AUTO_VALUE;
Colin Flashman
Community Expert
Community Expert
October 31, 2023

Did the frame have an object style? If so, the size and position of the object style could be changed.

If not, are the PDF pages imported from one document or many? If it is one 800pp PDF placed into ID, you could use the multipageimporter script to import all pages at once on its own layer and to an appropriate scale. The script is here: https://github.com/mike-edel/ID-MultiPageImporter/releases

If the answer wasn't in my post, perhaps it might be on my blog at colecandoo!