Merging Layers in Acrobat 8

So if you find you have a whole bunch of layers and you need to repeatedly throw them all together all the time, you can do this with javascript:

//Open Javascript Console
console.show();
var MAINocgLayerName = "Add Boundary Sets";
var mergedOCGArray = new Array();
var sourceOCGArray = this.getOCGOrder();
var OCGArray = this.getOCGs();
var sourceLayer;
var targetLayer;
//Find the source layer
for (var i=0; i&ltocgarray.length;)
{
if ( OCGArray[i].name == MAINocgLayerName )
{
targetLayer = OCGArray[i];
}
}
console.println("Target layer found: " + targetLayer.name);
// Merge the OCG order arrays into the target array:
for (var i=0; i < ocgarray.length)
{
if ( OCGArray[i].name != MAINocgLayerName )
{
console.println("Checking " +i + " " + OCGArray[i].name + "\n");
OCGArray[i].initState = targetLayer.initState;
OCGArray[i].intent = targetLayer.intent;
OCGArray[i].locked = targetLayer.locked;
OCGArray[i].name = targetLayer.name;
OCGArray[i].state = targetLayer.state;
console.println("Setting " + OCGArray[i].name + " to " + targetLayer.name + "\n")
}
}
mergedOCGArray[0] = targetLayer;
console.println("MergedOCGArray has : " + mergedOCGArray.length);
this.setOCGOrder(mergedOCGArray);

More details here:

http://www.verydoc.com/documents/acrojsguide/…

Comments are closed.