Skip to main content
Else DC
New Participant
October 2, 2017
Question

Batch-convert InDesign to PDF with a specific layer in all documents visible or invisible

  • October 2, 2017
  • 2 replies
  • 2205 views

For one client, I make 60 brochures every three months that need to be converted to PDF.
I have this wonderful batch-convert script that I discovered the first time I attended the Pepcon. So that has made my life a lot less boring for a while.

Only now that client asked me to make two sets of PDFs. That means that I need to make one layer visible or invisible before creating the PDFs.

Now I just open all the files and make this layer visible or invisible by hand in all 60 brochures.

Is there any one who could help me with a script that makes it possible to define the layers that need to be visible when creating the PDF for all 60 brochures?


For another client I make 72 brochures.
There I need to lock or unlock specific layers before I can do a GREP find and replace. Here too I am opening every document and locking and unlocking layers 72 times before I can start the action.

For the same job, I would like to find a way to merge InDesign files together into one editable document.
If documents can not be merged, it would also be helpful if there was a way to batch convert InDesign books to PDF docs.

This topic has been closed for replies.

2 replies

Kasyan Servetsky
Brainiac
October 2, 2017

For such a situation I wrote my Batch processor script. My conception was to break a complex task into a number of simple steps (scripts). I think even a first-time scripter can write a simple script performing only one task. For example, you can find loads of scripts that do something similar here on the forum and adjust them to your needs. As to me it takes a couple of minutes to write it.

Here are a few examples:

Make layer invisible/visible

main();

function main() {

    // The frontmost document

    var doc = app.activeDocument;

    // Get the layer by name

    var layer = doc.layers.itemByName("Layer 1");

    if (layer.isValid) { // If the layer exists, go on

        layer.visible = false; // true -- make visible; false -- make invisible

    }

}

Lock/unlock layer

main();

function main() {

    // The frontmost document

    var doc = app.activeDocument;

    // Get the layer by name

    var layer = doc.layers.itemByName("Layer 1");

    if (layer.isValid) { // If the layer exists, go on

        layer.locked = false; // true -- lock layer; false -- unlock layer

    }

}

Export to PDF -- Exports a PDF file to the same location as the InDesign document.

main();

function main() {

    // The frontmost document

    var doc = app.activeDocument;

    // PDF-preset name -- replace it with the preset name exacty as you see it in InDesign

    var pdfPreset = app.pdfExportPresets.itemByName("[High Quality Print]");

    // PDF file will be created in the same folder as the indd-file: the file path remains the same -- only extension is changed

    var pdfFile = new File(doc.fullName.absoluteURI.replace(/indd$/, "pdf"));

    // Export to PDF in foreground

    doc.exportFile(ExportFormat.PDF_TYPE, pdfFile, false, pdfPreset);

}

I commented every line so even if you know nothing about scripting, you can edit them: change the layer name, pdf preset name, pdf file location, etc.

For the same job, I would like to find a way to merge InDesign files together into one editable document.

Check out the Merge the two open documents by Dave Saunders. However, when I was testing it, I didn't get good results. I guess this happened because the documents I used for testing had some slight (visually unnoticeable) differences -- e.g. minor differences in styles. Six designers work for our magazine and everyone of them brings something of her own to the layout which is supposed to be strictly identical.

— Kas

Else DC
Else DCAuthor
New Participant
October 2, 2017

Hello Kas,

Thank you for your reply.

I'm sorry to say that I actually know nothing about scripting other than which folder to put it so that I can access it from InDesign.

I've saved your text as a jsx file and tried to run it, but it does nothing.

And I haven't got a clue about how to make it work.

Kasyan Servetsky
Brainiac
October 2, 2017

I posted the three scripts as an example, but you should put the real layer name, pdf preset name, etc. you use in your workflow. I can't know this.

Community Expert
October 2, 2017

The tasks you mentioned are not complex to achieve individually, but as you mentioned you already have a working scripts that needs integration of these changes, that would some work.

On another note people around here can help you if you provide some code that you tried that did not work as per you requirement. In case you need to get your work done without investing your time on it then you need to hire someone to fix this for you, there are many capable people here who would be willing to do the same.

-Manan

Else DC
Else DCAuthor
New Participant
October 2, 2017

Hello Manan,

If I would be able to get individual scripts for the tasks mentioned, I would be very happy.

The one script doesn't really need to be integrated with the other.

I'm just looking for some simple things:

• turn on/off visibility of layers in multiple InDesign documents

• lock/unlock layers in multiple InDesign documents

• batch convert multiple InDesign books to PDF (one PDF/book)

• a script that allows me to sequence a few pre-saved find/change tasks (text replacement and 'apply object styles')

Just these 4 (simple) scripts would be a huge help to me.

I'm only able to use a script. I haven't got a clue how to write one myself. So there is no code that didn't work