Export each spread in indesign as indesign snippet without using grouping.
var myPages = app.activeDocument.spreads.length;
var myObj = new Array();
for(var i = 0; i < myPages; i++){
var myPage = app.activeDocument.spreads.item(i);
myObj = app.activeDocument.spreads.item(i).pageItems;
// alert (myText.parentTextFrames(0).parent.name);
var myGroup = app.activeDocument.spreads.item(i).groups.add(myObj,undefined,Locatio nOptions.UNKNOWN,app.activeDocument.spreads.item(i));
myGroup.exportFile(ExportFormat.INDESIGN_SNIPPET, File("/c/test/snippet-" + i + ".idms"));
myGroup.ungroup();
}
I searched and tried and cannot find a direct method to export a ungroupped objects in single snippet file.
var obj = app.activeWindow.activePage.pageItems.everyItem();
obj.exportFile(ExportFormat.INDESIGN_SNIPPET, File("E:/testing.idms"));
This method also fails, it exports only the first item in the array.
Any way you have to group it. So that you'll have it in a single file.
Try this work around, Add a label to indicate to which layer it belongs to, and while importing it run a script to move it to its corresponding layers based on the labels that you assigned.
Green4ever
To add a label you could use the insertLabel method:
myPageItem.insertLabel("KeyString", "ValueString");
To extract it, do it like that:
myValueString = myPageItem.extractLabel("KeyString");
To use a value like the name of a layer, you could:
myPageItem.insertLabel("Layername", myPageItem.itemLayer.name);
To extract the layer name and apply it to the page item:
myPageItem.itemLayer = app.activeDocument.layers.itemByName(myPageItem.extractLabel("Layername");
Of course you can run into problems if the layer does not exist in the document where you place your snippet.
In that case you have to add a new layer with the appropriate name to the document.
app.activeDocument.layers.add({name:myPageItem.extractLabel("Layername")});
Or it may be that the layer is there, but locked! Then you first have to unlock teh layer.
Also: that easy approach will not take care for the "right" order layers are stacked, if they are visible or even locked. Does the rules of the source or the target document layer behaviour apply? You may or may not implement a routine to get that right. This is highly case dependend. If one or some of the layers already exist and you mix that with new added layers or you change the stacking order of layers you could easily contradict already established layer behaviour and wreck the layout of a whole document…
Uwe
North America
Europe, Middle East and Africa
Asia Pacific