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

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

Contributor ,
Jun 14, 2023 Jun 14, 2023

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
357
Translate
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)
...
Translate
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);

 

Translate
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

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

 

Translate
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
LATEST

For the info:

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

can be replaced by

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

 

Translate
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