Skip to main content
Known Participant
September 25, 2023
Question

Script to fit group of objects to page proportionally.

  • September 25, 2023
  • 2 replies
  • 1079 views

I need to go through a large document that have individual items on each page (text boxes, picture boxes, rectangles of different colors etc.)

At the moment I am doing this manually for each page:

 

1-group all items on the page

2-manually enlarge proportionally, and fit to page
(I use fn+Cmnd+Shift while resizing the group) so all objects including text and pictures would scale accordingly.

 

This is a repetitive task and seems that I will have to do the same on new documents I will recive. So I was wondering if there is a way of doing this with a script.

 

I found this:

https://community.adobe.com/t5/indesign-discussions/is-there-a-javascript-to-resize-a-frame-to-page-margin-bleed-or-slug/m-p/7288149

 

var doc = app.activeDocument;
var myPage = doc.pages[0];
var fit = myPage.bounds;
var myFrame = app.selection[0];
myFrame.geometricBounds = fit;

 

The above is similar to what I am after but it scales the objects, and the contents remain the same. So for instance, it will enlarge the text box but the text stays the same size.

 

Is there a way of scaling to fit the page with contents and and keeping the proportions? Maybe a shortcut or better still a script? Or maybe I could tweak the script above so that it scales pictures and text proportionally?

 

Any guidance or ideas welcome.

Thanks.

 

This topic has been closed for replies.

2 replies

Robert at ID-Tasker
Legend
September 25, 2023

Is it just so you can print it on a differennt size of the paper - or will you have to work on the contents later?

 

Known Participant
September 25, 2023

Hi Robert, thanks.

It is so that I can fit the different grouped elements to various documents.

These docs will have different (non standard) page sizes.

I should be able to ungroup and edit the different items if needed.

 

Robert at ID-Tasker
Legend
September 25, 2023

OK, so if proportions are different and you need to be able to edit - then what I was "suggesting" won't work - exporting as PDF and then resizing when importing into a new document.

 

Unfortunately, you are on a Mac so my ID-Tasker won't help you.

 

Community Expert
September 25, 2023

You'd have to get the horizontal and the vertical scale to fit the group to the page bounds. Then use the smallest value to scale the group, either using myGroup.horizontalScale and myGroup.verticalScale, or myGroup.resize (...). Then move the group to the top left of the page.

 

Scaling like that enlarges objects and text in the grouped frames.

Known Participant
September 25, 2023

Thanks Peter, I am just starting with scripting so I wil see if I can tweak the script above and make it work.