2 Replies Latest reply on Jan 20, 2014 5:51 AM by printerror

    Export Scripting Help

    printerror

      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

        • 1. Re: Export Scripting Help
          Mi_D Level 3

          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[l].visible=false

                  }

              }

          function exportPdf(){

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

                  myLayer[l].visible=true;

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

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

                  myLayer[l].visible=false;

                  }

             

              }

           

           

          function visibleLayer(){

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

                  myLayer[l].visible=true

                  }

              }

           

           

          Mi_D

          • 2. Re: Export Scripting Help
            printerror Level 1

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