Resize Your Documents to Fit One or More Objects on the Page
I often make graphics (such as logos or ads) in InDesign, but they’re in the middle of the page. So when it comes to exporting the graphic as a PDF or INDD or whatever, I get too much white space around the edges.
For example, I want to export the artwork on this page:
Before I export this page, I need to resize it to the size of the artwork. I could use File > Document Setup, but that’s a hassle because I don’t know how big it should be, and because after I resize the page, the artwork will probably not be in the middle of the page anymore.
So I use a different technique instead: the Page Tool. When you choose the Page tool in the Tools panel and click on a page in your document, it gets highlighted with side and corner handles (as in the image above). You can drag those handles and it looks like the page is being resized… but it’s just teasing you, because when you let go of the mouse button, the page snaps back to the way it was!
The Trick
Fortunately, there’s a trick: If you hold down the Option/Alt key when you drag a handle with the Page tool, then you really do change the page size. Try it! It’s cool.
So when I Option/Alt-drag the upper-left corner of the page down to the upper-left corner of the object (in this case, a text frame), it snaps against the object edge:
However, in the image above, you can see that I can’t quite get the lower-right corner up to the lower-right corner of the object. That’s because of the page margins. InDesign doesn’t let you make a page so small that the margins would overlap.
You’d think you could simply choose Layout > Margins and Columns to change the margins, but unfortunately that only changes them for the current page or spread. Instead, you first need to click the master page in the Pages panel. Then, with that selected, you can choose Margins and Columns. Set the Margins to zero, click OK, and then you’ll be able to reduce the page as small as you want:
Getting Just the Right Size
As I said earlier, the Page tool snaps the edge of the page to the edge of the object. In the example above, I have just one text frame, so it works great. But sometimes I find it helpful to draw out a blank frame (with no fill or stroke) around the artwork, and then use the Page tool to snap to it.
For example, if you know you want your final artwork to be exactly 10 cm x 20 cm, you could make a frame that size, position it around the artwork, and then use the Page tool to snap to the edges of that frame. (Then you could delete that frame if you want.)
Alternatively, you can just get the page size close with the Page tool, and then adjust it to the exact size you need by changing the W and H values in the Control panel:
Finally, when the page size is just right, you can use File > Export to get your JPEG, PNG, PDF, EPS, or whatever file format you need.
[By the way, don’t send me hate mail for the text in the graphics above! It’s just a reference to an old Steve Martin joke. But I have cats myself and I do not condone juggling them.]
And what about the “selection” option when exporting to JPEG and PNG ?
Jean-René: You are 100% correct about that. When making PNG and JPEG files, this technique is not as important. I use it mostly for PDF files, honestly.
ALSO, I should have mentioned the great, free Layout Zone add-on from automatication, which is amazing and lets you export selections to PDF, INDD, and other formats.
Very cool.
Personally I wish I could remove that thing from my tool bar. I’m always selecting it accidentally.
Why not just hold on a pc, control alt C that makes a perfect bounding box around any indesign item. Now just export the selection. Why the whole page. Please explain. Long time Indesign user. You can still export as pdf/
Ken: Sorry, I don’t know what Ctrl-Alt-C does in Windows. Are you talking about making a bitmapped screen capture?
Ctrl-Alt-C is “Fit frame to content”. I think Ken misunderstood the purpose of your trick.
David,
This cries out for a script! Well, I’ve used this one for a while now:
(function(){
if (app.documents.length > 0 && app.documents[0].pages[0].pageItems.length === 1) {
var frame = app.documents[0].pages[0].pageItems[0];
var gb = frame.geometricBounds;
app.documents[0].pages[0].marginPreferences.properties = {top: 0, left: 0, bottom: 0, right: 0};
app.documents[0].documentPreferences.pageWidth = gb[3]-gb[1];
app.documents[0].documentPreferences.pageHeight = gb[2]-gb[0];
app.documents[0].zeroPoint = [0,0];
frame.move([0,0]);
}
}());
In case anyone is wondering, Peter’s script works by having one frame (or many frames but as one group) on a blank page that is to become the size of the finished page. Run the script and the page size changes to that of the frame or group.
I need to change my last comment slightly. When I said “blank page” I meant “otherwise blank page” – oops.
Thanks for making that clear, Colin.
Is it possible for the script to change the size of a specific page, instead of making the change document-wide?
Sure:
(function() {
if (app.documents.length === 0 || app.selection.length !== 1) {
alert ('Open a document and/or select a single page item.'); exit();
}
app.scriptPreferences.measurementUnit = MeasurementUnits.POINTS;
var ruler = app.documents[0].viewPreferences.rulerOrigin;
app.documents[0].viewPreferences.rulerOrigin = RulerOrigin.PAGE_ORIGIN;
var page = app.selection[0].parentPage;
var frame = page.pageItems[0];
var gb = frame.geometricBounds;
app.documents[0].zeroPoint = [0,0];
frame.move ([0,0]);
page.marginPreferences.properties = {top: 0, left: 0, bottom: 0, right: 0};
page.resize (CoordinateSpaces.INNER_COORDINATES,
AnchorPoint.TOP_LEFT_ANCHOR,
ResizeMethods.REPLACING_CURRENT_DIMENSIONS_WITH,
[gb[3]-gb[1], gb[2]-gb[0]]
);
app.documents[0].viewPreferences.rulerOrigin = ruler;
}());
Peter
I have a (vaguely) similar situation. Let’s say I have a multi-page document which is 6×9 with 1 inch margins all round, and I want to publish this via Kindle Textbook Creator without the wide margins but maintaining the same layout.
Ideally I’d like to be able to change the document size and the margins in one operation so that everything stays in place. In practice I change margins first, then document size and end up with some layout assisting to do…for reasons which I can’t quite understand!
Roger — Enable ‘Layout Adjustment’ in the Margins and Columns window and you should be fine.
Thanks Peter, but I did have that option checked, that’s why I was surprised when there were still some alignment issues. All the graphics in the book are aligned to page margins. This is CS5 by the way, I’d try it in CC2015 if only I could get it past ‘enabling trackers’ at startup!
While publishing these Islamic books we keep in mind the interests of people around.
Besides this, it’s much easier to gift books to someone rather than the pricy gadgets.
Books in translation can a bit taxing to read because of all the technical
terms and what-nots.
I can’t believe no one has commented on the cat juggling reference! I was a big fan of that album, David, and we would often quote it around the house. :)
Just tried it, works great.
So helpful! Thank you!!
Thanks so much, this is precisely what I was looking for.
Peter, many thanks for that script tweak, it works great!
This script works pretty well and it’s cheap, https://sellfy.com/p/LthK/
Many thanks to Peter Kahrel!
How is it possible to add a ‘group’ command before everything?
Dario — You want to group all page items on a page? It that’s the case, replace this line:
var frame = page.pageItems[0];
with this one:
var frame = page.groups.add (page.pageItems.everyItem().getElements());
Then select one of the page items on the page and run the script.
P.