0

How can I extract a list of all layer names into either a text or .csv file.? What Acrobat or scripting tools are available to do this task?

The list will be used to create a table communicating to commercial printers what layers should be activated for any particular print run. Each PDF may contain 15 to 50 such layers, combined to create 5 to 30 unique print pieces. Our PDFs are exported directly from InDesign.

I expect the resulting text to be pastable into a column within an excel file, or for the resulting .csv file to contain the layer names within individual cells of column one.

5
  • indesign supports vbscript, applescript, and javascript
    – Yorik
    Oct 24 '19 at 18:53
  • 1
    Have you talked to the printer if this is something they offer? I work in print myself, and I wouldn't want to take the responsibility to do all that layer toggling. i would ask the client to send separate PDFs. Furthermore, the program used to send the PDFs to print might not offer the possibility to toggle layers. Most print shops use dedicated software to print/create offset sheets - not necessarily Acrobat.
    – Wolff
    Oct 28 '19 at 18:12
  • Wolff -- your response is appreciated. Your are correct about working with the print shop(s) to learn their preferences and capabilities. Ours prefer that we provide the complex multi-layer PDF as one document, along with a 'perfectly accurate' list of layer names contained in that PDF. Their software can activate pages/layers on the fly for direct mail. We currently have script to save layer names to clipboard, then manually paste to text. It works, but remains too manual a process for my preferences.
    – BStone
    Jul 16 at 15:42
  • @BStone, OK. I'm making a script for you right now. I think it's pretty simple.
    – Wolff
    Jul 16 at 15:44
  • Could you post the script you have now? I don't know indesign scripting but file IO is the same along all the Adobe products to my knowledge. If your issue is writing to a file it should be straightforward Jul 16 at 15:49
1

Here is a script that:

  • Prompts you for a destination folder.
  • Creates a new text file with the same name as the active document.
  • Writes the name of each layer in the active document to the text file.
  • Saves the text file and closes it.

Each line in the script is commented.

// Open dialog to select path for text file
var textFilePath = Folder.selectDialog("Select a destination for the layer list text file.");

// Set text file name to active document name + .txt
var textFileName = app.activeDocument.name + ".txt";

// Create text file
var textFile = new File(textFilePath + "/" + textFileName);

// Set text file encoding
textFile.encoding = "UTF-8";

// Open text file
textFile.open("w");

// Loop through all layers of active document
for (var i = 0; i < app.activeDocument.layers.length; i++) {

    // Write layer name to textfile
    textFile.write(app.activeDocument.layers[i].name + "\n");

}

// Close text file
textFile.close();

If you instead want a .csv file, you should be able to just add a "," after each layer name instead of a "\n", and change the extension from .txt to .csv.

1
  • @BStone, no accept or bounty? Didn't it work?
    – Wolff
    Jul 26 at 10:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.