I have an Indesign CS5.5 document with one page and multiple artworks on separate layers. I need to move each layer to a separate page and then to separate documents.
Is there any quick way of doing this, or script that has been written?
Thanks, in advance.
@ maxrus2012 – layers are document properties, NOT page properties. So you cannot move a layer to a different page.
Instead what I guess you want is that you like to move all page items on page one of a specific layer to a different page.
The following script will duplicate all page items per layer to new pages in the same document. You can undo the script.
app.scriptPreferences.userInteractionLevel = UserInteractionLevels.interactWithAll;
app.doScript(_DistributeAllPageItemsOnCurrentPageToNewPages, ScriptLanguage.JAVASCRIPT, [], UndoModes.ENTIRE_SCRIPT, "Distribute all page items on current page to new pages");
function _DistributeAllPageItemsOnCurrentPageToNewPages(){
var d = app.documents[0];
var allLayers = d.layers;
allLayers.everyItem().visible = true;
allLayers.everyItem().locked = false;
for(var n=0;n<allLayers.length;n++){
if(allLayers[n].pageItems.length>0){
var pageItemsOnLayer = allLayers[n].pageItems.everyItem();
//Unlock every page item on the layer:
pageItemsOnLayer.locked = false;
//Make all page items visible on the layer:
pageItemsOnLayer.visible = true;
var myGroup = d.groups.add(pageItemsOnLayer);
var newPage = d.pages.add();
var myDupOfGroup = myGroup.duplicate(newPage);
myDupOfGroup.ungroup();
myGroup.ungroup();
};
};
}; //END function "_DistributeAllContentsOnCurrentPageToNewPages()"
Uwe
Message was edited by: Laubender Used advanced editor get syntax highlighting after posting
.. or change the script slightly, so it zooms in on the actual error line.
Put comment slashes before the line that starts with app.doScript:
// app.doScript ..
so it will be ignored, and add this line
_DistributeAllPageItemsOnCurrentPageToNewPages();
directly below it. Then re-run and see what it tells you.
(The doScript construction allows an easy One Step Undo of the entire script, but unfortunately it has the side effect that any errors "inside" the script will be reported as an error from the command that executed the script. Calling the function directly will hopefully show where it fails inside the function.)
Message was edited by: [Jongware] Gosh, still no way of adding Syntax Hi-lite without post-editing. "Knock knock, anyone there?"
Hi Laubender,
I don't know how to post a file for you to download and don't have a real file to hand.
I have attached a screengrab to illustrate though, which shows a Document with layer and page panels visible.
The real document has complex artwork with a full execution of artwork on each layer.
So instead of using separate pages for each artwork they used separate layers.
I hope this helps you understand the problem better.
There is not one document for me to process but many and it will be recurring.
Thanks,
Max
@Max – ok. I think I made the mistake to assume that there are more than one page items on a single layer. If there is only one page item, my script will fail because I cannot make a group object out of one single page item.
But we can correct that, if we ommit the grouping if there is only one page item in the layer:
app.scriptPreferences.userInteractionLevel = UserInteractionLevels.interactWithAll;
app.doScript(_DistributeAllPageItemsOnCurrentPageToNewPages, ScriptLanguage.JAVASCRIPT, [], UndoModes.ENTIRE_SCRIPT, "Distribute all page items on current page to new pages");
function _DistributeAllPageItemsOnCurrentPageToNewPages(){
var d = app.documents[0];
var allLayers = d.layers;
allLayers.everyItem().visible = true;
allLayers.everyItem().locked = false;
for(var n=0;n<allLayers.length;n++){
if(allLayers[n].pageItems.length>1){
var pageItemsOnLayer = allLayers[n].pageItems.everyItem();
//Unlock every page item on the layer:
pageItemsOnLayer.locked = false;
//Make all page items visible on the layer:
pageItemsOnLayer.visible = true;
var myGroup = d.groups.add(pageItemsOnLayer);
var newPage = d.pages.add();
var myDupOfGroup = myGroup.duplicate(newPage);
myDupOfGroup.ungroup();
myGroup.ungroup();
};
if(allLayers[n].pageItems.length===1){
var myPageItem = allLayers[n].pageItems[0];
myPageItem.locked = false;
myPageItem.visible = true;
var newPage = d.pages.add();
myPageItem.duplicate(newPage);
};
};
}; //END function "_DistributeAllContentsOnCurrentPageToNewPages()"
Uwe
Message was edited by: Laubender Did syntax highlighting by advanced editor
@Max
For that we need a naming scheme for the different single page documents you want to save.
But I fear currently I have no time to implement that.
There are several scripts floating around in the web which can do that for you.
See for example the following script by Hans Haesler (split document):
DokumentAufsplitten_512d.jsx
at (Mac version in German):
or (Windows version in German):
In case you do not understand the German settings here is a two-step-guide to your single page documents:
1. Check the proper feature for splitting pages (every page should become a document of its own):
2. Start page numbering with:
If you want every single document in its own directory check: "Artikel-Ordner erzeugen".
Uwe
North America
Europe, Middle East and Africa
Asia Pacific