Skip to main content
Participant
January 17, 2014
Question

Export Scripting Help

  • January 17, 2014
  • 1 reply
  • 574 views

Oh great script gurus... I'm no code monkey and have a very basic knowledge of scripting, however I have a workflow that is just begging for an autoscript.

Our files are laid out as such:

Project_Number_Page1_Base.indd

Project_Number_Page2_Base.indd

(etc.)

Within each file are multiple layers of course:

Guides

Background

A

B

C

(etc.)

When we export to PDF, we export as follows:

Project_Number_Page1_A.pdf

Project_Number_Page1_B.pdf

Project_Number_Page1_C.pdf

Project_Number_Page2_A.pdf

Project_Number_Page2_B.pdf

Project_Number_Page2_C.pdf

(etc)

Within each file, "Background" is always present, and the A, B, and C layers switch off respectively.

Current process is to show/hide each layer and export one at a time. I'm certain there's a way to script this for pages where we have 8 or 10 different layers.

I, however, lack the scripting skills to pull this off. Can you guys lend a hand? Please, slainté, prost, aloha, konichiwa, and thank you!

Brett

This topic has been closed for replies.

1 reply

Inspiring
January 18, 2014

hi check below code,

var myDoc = app.activeDocument;

var myPages = myDoc.pages;

var myLayer = myDoc.layers;

var myFilePath = myDoc.filePath;

var myDocName = myDoc.name;

var myBaseName=myDocName.split(".indd")[0];

hidelayer();

exportPdf();

visibleLayer();

function hidelayer(){

    for (var l=0; myLayer.length>l; l++){

        myLayer.visible=false

        }

    }

function exportPdf(){

    for (var l=0; myLayer.length>l; l++){

        myLayer.visible=true;

        mypdfFilePath = new File(myFilePath + "/" + myBaseName+"_"+ myLayer.name + ".pdf");

         myDoc.exportFile(ExportFormat.pdfType, mypdfFilePath, false);

        myLayer.visible=false;

        }

   

    }

function visibleLayer(){

    for (var l=0; myLayer.length>l; l++){

        myLayer.visible=true

        }

    }

Mi_D

Participant
January 20, 2014

Thanks Mi, I'll tinker with it and see if I can get it to work. Wish I knew my way around JS.