Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
10

Setting "Number of Pages" for a Parent Page via javascript

Contributor ,
Jun 14, 2023 Jun 14, 2023

Copy link to clipboard

Copied

Greetings,

 

How can I set the "Number of Pages" for a Parent Page to equal 1 or any number via javascript?

1.jpg

Thanks for any help on this 🙂

TOPICS
How to , Scripting

Views

250
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
community guidelines

correct answers 1 Correct answer

Community Expert , Jun 14, 2023 Jun 14, 2023

To alter the "number of pages" of a parent spread is adjusted by adding or removing the spread's pages. For example:

var doc = app.activeDocument;
$.writeln('Number of pages of first parent spread: ' + doc.masterSpreads[0].pages.length);
doc.masterSpreads[0].pages.add();
$.writeln('Number of pages of first parent spread: ' + doc.masterSpreads[0].pages.length);
doc.masterSpreads[0].pages.lastItem().remove();
$.writeln('Number of pages of first parent spread: ' + doc.masterSpreads[0].pages.length)
...

Votes

Translate
Community Expert ,
Jun 14, 2023 Jun 14, 2023

Copy link to clipboard

Copied

To alter the "number of pages" of a parent spread is adjusted by adding or removing the spread's pages. For example:

var doc = app.activeDocument;
$.writeln('Number of pages of first parent spread: ' + doc.masterSpreads[0].pages.length);
doc.masterSpreads[0].pages.add();
$.writeln('Number of pages of first parent spread: ' + doc.masterSpreads[0].pages.length);
doc.masterSpreads[0].pages.lastItem().remove();
$.writeln('Number of pages of first parent spread: ' + doc.masterSpreads[0].pages.length);

 

Votes

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
community guidelines
Contributor ,
Jun 14, 2023 Jun 14, 2023

Copy link to clipboard

Copied

Thanks @m1b , I was able to just add the code below for setting the Parent to 1 page based on your snippet.

graphicTemplate.masterSpreads[0].pages.lastItem().remove();

 

Votes

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
community guidelines
People's Champ ,
Jun 15, 2023 Jun 15, 2023

Copy link to clipboard

Copied

LATEST

For the info:

doc.masterSpreads[0].pages.lastItem()

can be replaced by

doc.masterSpreads[0].pages[-1];

 

Votes

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
community guidelines