Autofit page size

New Here ,
Dec 20, 2017

Copy link to clipboard

Copied

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

Adobe Community Professional
Correct answer by Peter Kahrel | Adobe Community Professional

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

TOPICS
Scripting

Views

806

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Autofit page size

New Here ,
Dec 20, 2017

Copy link to clipboard

Copied

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

Adobe Community Professional
Correct answer by Peter Kahrel | Adobe Community Professional

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

TOPICS
Scripting

Views

807

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Dec 20, 2017 0
Adobe Community Professional ,
Dec 21, 2017

Copy link to clipboard

Copied

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Dec 21, 2017 0
New Here ,
Dec 21, 2017

Copy link to clipboard

Copied

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

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Dec 21, 2017 0
Adobe Community Professional ,
Dec 22, 2017

Copy link to clipboard

Copied

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

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Dec 22, 2017 0
New Here ,
Dec 22, 2017

Copy link to clipboard

Copied

Peter Hi!

Thank you very much for your very quick reply and also explanation and also this script!!!

It works very well and that's exactly what i wanted!!

1- One thing is weird, after the script action, everything on the page is grouped. I can see the line 14 doing this. But i wonder if it is possible to undo the grouping at the end of the action

2- If we would like to add some margin, i thought it was as easy as modifying the values line 19, but it doesn't work... if i put 5 in place of top: 5 for example...

Regards

Miran

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Dec 22, 2017 0
Adobe Community Professional ,
Dec 22, 2017

Copy link to clipboard

Copied

> I wonder if it is possible to undo the grouping at the end of the action

Sure, no problem

> If we would like to add some margin . . .

Sure, no problem. Add your margins in line 15. These are in your document's measurement units.

if (!app.documents.length) {

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

}

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]);

  m = {top: 5, left: 5, bottom: 5, right: 5};

  pages.marginPreferences.properties = m;

  pages.resize (CoordinateSpaces.INNER_COORDINATES,

    AnchorPoint.TOP_LEFT_ANCHOR,

    ResizeMethods.REPLACING_CURRENT_DIMENSIONS_WITH,

    [gb[3] - gb[1] + m.left + m.right, gb[2] - gb[0] + m.top + m.bottom]

  );

  frame.move ([m.left, m.top]);

  try {

    frame.ungroup();

  } catch (_) {

  }

}

P.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Dec 22, 2017 0
lemiran LATEST
New Here ,
Dec 23, 2017

Copy link to clipboard

Copied

Hi Peter

Thank you very much again!

Very useful and very very appreciated!

Hope i could help you one day

Regards from France

Miran

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Dec 23, 2017 0