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

Data merge with alternate layouts

Participant ,
Jan 31, 2019 Jan 31, 2019

Copy link to clipboard

Copied

I'm wondering if there's a way to have merged document pages stay in the same layout section as the source file. Right now I've been manually selecting the pages and moving them to their appropriate column. Is there another way to do this so that each record is listed in the same layout as its source?Screen Shot 2019-01-31 at 11.58.51 AM.png

TOPICS
Scripting

Views

3.1K

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

correct answers 1 Correct answer

Participant , Feb 11, 2019 Feb 11, 2019

Hi Dan,

You do something like this, or perhaps this will help get you started:

var doc = app.activeDocument;

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

    if(doc.pages.item(i).appliedMaster.name  == 'A-Master1') {

        // DO SOMETHING

    }

    else if(doc.pages.item(i).appliedMaster.name == 'B-Master2') {

        // DO SOMETHING

     }

     else {

        // DO SOMETHING

     }

}

The 'A-Master1' and 'B-Master2' are just what I named the master pages. Replace with the names you have. You may have to use

...

Votes

Translate

Translate
Adobe Employee ,
Jan 31, 2019 Jan 31, 2019

Copy link to clipboard

Copied

Hi Daniel,

This might be possible through scripting, hence moving the discussion to InDesign Scripting forum.

Regards,

Srishti

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 ,
Feb 08, 2019 Feb 08, 2019

Copy link to clipboard

Copied

I've written up a few solutions that may help:

https://indesignsecrets.com/changing-layouts-during-a-data-merge.php

https://colecandoo.com/2018/04/05/data-merging-to-specific-pages/

If the answer wasn't in my post, perhaps it might be on my blog at colecandoo!

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
Participant ,
Feb 11, 2019 Feb 11, 2019

Copy link to clipboard

Copied

Thanks Colin! I'm going to try using that first technique for a few other projects. But I'm not sure how it would work with different layouts as well as different page sizes?

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
Participant ,
Feb 11, 2019 Feb 11, 2019

Copy link to clipboard

Copied

I was wondering: Since each of the alternate layouts uses a different master, is there a way to select all pages that use a specific master, or color label? That could be another way for me to semi-automate this process.

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
Participant ,
Feb 11, 2019 Feb 11, 2019

Copy link to clipboard

Copied

Hi Dan,

You do something like this, or perhaps this will help get you started:

var doc = app.activeDocument;

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

    if(doc.pages.item(i).appliedMaster.name  == 'A-Master1') {

        // DO SOMETHING

    }

    else if(doc.pages.item(i).appliedMaster.name == 'B-Master2') {

        // DO SOMETHING

     }

     else {

        // DO SOMETHING

     }

}

The 'A-Master1' and 'B-Master2' are just what I named the master pages. Replace with the names you have. You may have to use a Switch statement if you have a lot of master pages. Hope this helps.

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
Participant ,
Feb 11, 2019 Feb 11, 2019

Copy link to clipboard

Copied

Thank you!

I am going through adobe's cs6 scripting tutorial and javascript guides, and will figure out how to // DO SOMETHING

Are there any other recommended resources that are go-tos for indesign scripting?

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
Participant ,
Feb 11, 2019 Feb 11, 2019

Copy link to clipboard

Copied

This is a good place to start imo - B E - YouTube a decent amount of indesign scripting basics and such.

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
Participant ,
May 01, 2019 May 01, 2019

Copy link to clipboard

Copied

I've written the following, but I'm stuck when I try to move the current page to a specific section. I'm not sure if I'm using .move or .sections correctly. Where am I going wrong here?

Thanks

var myDoc = app.activeDocument;

//find number of masters in document, each of which corresponds to an alternate layout

var myLayouts = myDoc.masterSpreads.length;

//for each page in the document

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

   //cycle through all the layouts

   var currentSection = myDoc.sections[(i % myLayouts)];

   //move current page to the end of current section in cycle


  myDoc.pages.item(i).move(LocationOptions.after,currentSection.pages.item(-1));


  };

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 ,
May 08, 2019 May 08, 2019

Copy link to clipboard

Copied

Youtuber Daniel Solis also has a unique way of doing something similar, although his technique has the same page size, but different page layouts. Definitely worth watching his video:Card Design Layout Template "Mars Runner" [Patreon Download] - YouTube

If the answer wasn't in my post, perhaps it might be on my blog at colecandoo!

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
Participant ,
May 08, 2019 May 08, 2019

Copy link to clipboard

Copied

LATEST

Interesting, I like the double space to line break GREP trick using max tracking from that vid. I'll have to see if that setup might work better for this the next time I do it.

I found a way to achieve my original goal using the absolute numbering for each page without using a section as a reference. Multiplying with zero indexing threw me off a bit, but eventually got the below to work.

var myDoc = app.activeDocument;

//number of alternate layouts

var myLayouts = myDoc.sections.length;

//for each spread in the document

for(var i = 1 ; i <= myDoc.spreads.length; i++) {

        //find position it needs to be moved to by finding its location in grid

        var myRow = Math.ceil(i / myLayouts);

        var myColumn = (i - 1) % myLayouts + 1;

        var myLocation = (myRow * myColumn - 1);

        //move it

        myDoc.spreads[i - 1].move(LocationOptions.BEFORE,myDoc.spreads[myLocation]);

};

Thanks!

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