Copy link to clipboard
Copied
Hello,
Background: The job I'm working on was created using datamerge. Its a postcard that has a common master page background. I merged in an address and map.
As expected I now have over 200 pages of postcards with the merged background, address, and map. I need to export them into separate files that have individual names. So what I would like to do is somehow move the pages into layers on a single page and name the layers the file names I need, then export them using the script, "PageExporterUtility". For those not familiar PageExporter lets you choose a base layer and variable data layers on top and creates and individual file for each using the name of that layer.
The problem I'm running into is that I can't find a way to move all of the pages into layers on one page. I found was able to make each page it's own layer but it stays on that page. Here's my script so far below.
Thanks for your help.
Jeff
for(var p=0; p<document.pages.length; p++)
{
var myPageItems = document.pages
.pageItems.everyItem().getElements();
var myLayerPage = (p+1);
for(var i=0;i<myPageItems.length;i++)
{
try{var myLayer = app.activeDocument.layers.add ({name: "Page " + myLayerPage});}catch(e){}
myPageItems.itemLayer = "Page " + myLayerPage;
}
}
Hi ixladxi,
You were very close... I used your script above and edited as such, notice the last part (added var doc for my script execution purposes):
var doc = app.activeDocument;
for(var p=0; p<document.pages.length; p++) {
var myPageItems = document.pages
.pageItems.everyItem().getElements();
var myLayerPage = (p+1);
for(var i=0; i < myPageItems.length; i++) {
try {
var myLayer = app.activeDocument.layers.add ({name: "Page " + myLayerPage});
} cat
...Copy link to clipboard
Copied
I guess I should mention that this is for 2018 CC.
Copy link to clipboard
Copied
Hi ixladxi,
You were very close... I used your script above and edited as such, notice the last part (added var doc for my script execution purposes):
var doc = app.activeDocument;
for(var p=0; p<document.pages.length; p++) {
var myPageItems = document.pages
.pageItems.everyItem().getElements();
var myLayerPage = (p+1);
for(var i=0; i < myPageItems.length; i++) {
try {
var myLayer = app.activeDocument.layers.add ({name: "Page " + myLayerPage});
} catch(e) {}
myPageItems.itemLayer = "Page " + myLayerPage;
}
}
var myPage = doc.pages.add();
for(var x = 0; x < doc.layers.length; x++) {
doc.layers
}
It will add a page at the end of the document and duplicate all the created layers to it.
Hope that helps.
Copy link to clipboard
Copied
Thank you so much! This worked. It combines it all on the last page.
Copy link to clipboard
Copied
Benreyn This works very well! I have some before and after steps that I would like to add in order to automate a portion of my workflow. I'm more familiar with AppleScript than .jsx and believe I will need to jump from Excel to BBedit to InDesign to accomplish what I'm envisioning.
My process will be extracting 2 columns of tabbed data, cleaning spaces & line endings, InDesign Data Merge, this script, and moving the resulting layers to the working document.
I want to take a shot at doing it myself but would greatly appreciate your thoughts and or warnings if any.
Thanks!
Copy link to clipboard
Copied
If you still had access to the original un-merged INDD file, would my Data Merge to Unique Names script be of use? Here's a video of it in action: Episode 1: Data Merge to Unique Names - InDesign Javascript by Colecandoo - YouTube