Skip to main content
Known Participant
December 20, 2017
Answered

Autofit page size

  • December 20, 2017
  • 2 replies
  • 3758 views

Hi everyone

I'm using Indesign since the beginning and know it very well.

I wonder if there is a trick to automatically fit the page size to its content...

Why?

Today i'm on a new project automated with EasyCatalog plugin and then i'm generating dozens of pages with different contents. Some of them are 10cm height, others are 25cm...

Thank you for your ideas ans suggestions

Regards

Miran

This topic has been closed for replies.
Correct answer Peter Kahrel

Miran --

> i don't understand how in indesign i could adapt the page in a one click action to the content

You can't, that was the point of David Blatner's post. The nearest you get to Illustrator's functionality is a script (the point of my reply to David), and if you want Illustrator's one-click functionality, you can assign a keyboard shortcut to the script.

So you're after a way of applying the script in that link to all pages in your document, correct? That's not too hard:

if (!app.documents.length) {

  alert ('Open a document.'); exit();

}

// Set up the document

app.scriptPreferences.measurementUnit = MeasurementUnits.POINTS;

app.documents[0].zeroPoint = [0,0];

app.documents[0].viewPreferences.rulerOrigin = RulerOrigin.PAGE_ORIGIN;

pages = app.documents[0].pages.everyItem().getElements();

for (i = 0; i < pages.length; i++) {

  if (!pages.pageItems.length) continue;

  if (pages.pageItems.length > 1) {

    pages.groups.add (pages.pageItems.everyItem().getElements());

  }

  frame = pages.pageItems[0];

  gb = frame.geometricBounds;

  frame.move ([0, 0]);

  pages.marginPreferences.properties = {top: 0, left: 0, bottom: 0, right: 0};

  pages.resize (CoordinateSpaces.INNER_COORDINATES,

    AnchorPoint.TOP_LEFT_ANCHOR,

    ResizeMethods.REPLACING_CURRENT_DIMENSIONS_WITH,

    [gb[3]-gb[1], gb[2]-gb[0]]

  );

}

Peter

2 replies

Community Expert
September 25, 2021

Hi Joseph,

do you mean that you want to unlock all objects in all layers, locked or not?

Do this with this code:

app.documents[0].layers.everyItem().locked = false;
app.documents[0].pageItems.everyItem().locked = false;

 

Regards,
Uwe Laubender

( ACP )

dublove
Legend
November 17, 2024

Hi @Laubender , It's rare to see you out writing scripts.

Type area fits the picture not much use.


Reverse. It is more useful.
How to write picture fit type area,
And the picture fits the bleed,
And picture fit column.

 

Thank you.

Peter Kahrel
Community Expert
Community Expert
December 21, 2017
lemiranAuthor
Known Participant
December 22, 2017

Hi Peter

I thank you for your link. But it does't really help.

I already know this tool and use the similar tool on Illustrator to adapt my pages or workspaces (plan de travail in french) to my artwork or the contents on it.

1- i don't understand how in indesign i could adapt the page in a one click action to the content... without knowing its dimensions. This is a normal behavior in Illustrator for example, by a double click with the tool similar to the page tool (i ignore its nam in english sorry).

2- as i explained before, i have a very big file with dozens of pages and i wonder if there is a ay to fit them quickly (and not manually one by one) to their content...

Regards

Miran

Peter Kahrel
Community Expert
Peter KahrelCommunity ExpertCorrect answer
Community Expert
December 22, 2017

Miran --

> i don't understand how in indesign i could adapt the page in a one click action to the content

You can't, that was the point of David Blatner's post. The nearest you get to Illustrator's functionality is a script (the point of my reply to David), and if you want Illustrator's one-click functionality, you can assign a keyboard shortcut to the script.

So you're after a way of applying the script in that link to all pages in your document, correct? That's not too hard:

if (!app.documents.length) {

  alert ('Open a document.'); exit();

}

// Set up the document

app.scriptPreferences.measurementUnit = MeasurementUnits.POINTS;

app.documents[0].zeroPoint = [0,0];

app.documents[0].viewPreferences.rulerOrigin = RulerOrigin.PAGE_ORIGIN;

pages = app.documents[0].pages.everyItem().getElements();

for (i = 0; i < pages.length; i++) {

  if (!pages.pageItems.length) continue;

  if (pages.pageItems.length > 1) {

    pages.groups.add (pages.pageItems.everyItem().getElements());

  }

  frame = pages.pageItems[0];

  gb = frame.geometricBounds;

  frame.move ([0, 0]);

  pages.marginPreferences.properties = {top: 0, left: 0, bottom: 0, right: 0};

  pages.resize (CoordinateSpaces.INNER_COORDINATES,

    AnchorPoint.TOP_LEFT_ANCHOR,

    ResizeMethods.REPLACING_CURRENT_DIMENSIONS_WITH,

    [gb[3]-gb[1], gb[2]-gb[0]]

  );

}

Peter