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

how can I copy a master-page as a new page in the same document?

New Here ,
Sep 18, 2024 Sep 18, 2024

Copy link to clipboard

Copied

 

I have a master page:

var master = doc.masterSpreads.itemByName("B-Parent");

I want that as a new page after my last page. I dont want that new page have that assigned master page "B-Parent", I want that new page be a copy of the master-page, having all items the master page has itself, but not the Items that the master-page inherits from its master-page:

So, if B-Parent has some text-frames and and an image and has itself the A-Parent as master which has some background etc., the new page should end up mastered by A-parent (B-Parents master) and should have a copy of B-Parents text-frames and its image.

How can I do that?

var master = doc.masterSpreads.itemByName("B-Parent");
var newPage = app.activeDocument.pages.add();
/*
... how can I copy the content of master into newPage? ...
*/
newPage.appliedMaster = master.appliedMaster;
TOPICS
How to , Scripting

Views

59

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
community guidelines
Community Expert ,
Sep 18, 2024 Sep 18, 2024

Copy link to clipboard

Copied

Select everything on the B-Parent, copy, paste-in-place on the newly created page, apply A-Parent. 

 

Of course, you can apply master first - doesn't matter. 

 

Just recreate steps that you would've to do manually. 

 

Votes

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
community guidelines
Community Expert ,
Sep 18, 2024 Sep 18, 2024

Copy link to clipboard

Copied

LATEST

Apply Parent A, then do use the .override function function for every pageItem on B. 

Pseudocode is: 

var mb = Parent B

 

Edit: Duh that won't work since B isn't applied. You'll need to distinguish the B items from the A items, maybe through layer naming or labels, then iterate through those and duplicate them to newPage

for allPageItems on mb, api[i].override(newPage)

 

Votes

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