5 Replies Latest reply on Apr 28, 2014 3:32 AM by FeralDB

    A Script for Conditional Text Batch Export

    yoitsrobj

      Hi, I was directed into this subforum with this question:

       

      I have a document with nearly 200 versions of conditional text that has to be individually swapped out and exported to pdf. I genearlly just do this one at a time all the way though.

       

      Is there a way to batch the export of these pdfs? I've been scouring the internet for a soultion but can't seem to find one. I am on CS4 still if it matters. Thanks!

        • 1. Re: A Script for Conditional Text Batch Export
          -hans- Level 4

          Hi,

           

          as it's late out here: very basically tested ...

           

          var nameOfThePDFExportPresetYouWantToUse = 'MyPdfPreset' //please don't forget to set!
          
          var currDoc = app.activeDocument;
          var currFilePath = currDoc.filePath.absoluteURI + '/';
          var currFileName = currDoc.name.replace(/.indd/, '');
          var currConditions = currDoc.conditions;
          //set all conditions visible to false
          currConditions.everyItem().visible = false;
          
          l = currConditions.length;
          x = 0;
          //cycle thru conditions
          while(l--){
              x = x+1;
          currCondition =     currConditions[l];
          //set actual condition visible to true
          currCondition.visible = true;
          //set pdfName
          var exportTo = File(currFilePath + currFileName + '_' + x +'.pdf');
          //export PDF
          currDoc.exportFile(ExportFormat.PDF_TYPE, exportTo,false,  nameOfThePDFExportPresetYouWantToUse);
          //set actual condition visible to false
              currCondition.visible = false;
              }
          

           

          Hope it'll work

           

          Hans-Gerd Claßen

          • 2. Re: A Script for Conditional Text Batch Export
            yoitsrobj Level 1

            it took a second but it is working now! Thanks a lot!


            If I wanted to get the file name to have the conditions name in it I would change the exportTo to have something along the lines of currentConditionName or something similar I would assume?

            • 3. Re: A Script for Conditional Text Batch Export
              -hans- Level 4

              Hi,

               

              no Problem Take a look at the exportline too. you can choose between backgroundexport and normal export.

               

              var nameOfThePDFExportPresetYouWantToUse = 'MyPdfPreset' //please don't forget to set!
              
              var currDoc = app.activeDocument;
              var currFilePath = currDoc.filePath.absoluteURI + '/';
              var currFileName = currDoc.name.replace(/.indd/, '');
              var currConditions = currDoc.conditions;
              //set all conditions visible to false
              currConditions.everyItem().visible = false;
              
              l = currConditions.length;
              //cycle thru conditions
              while(l--){
              currCondition =     currConditions[l];
              //set actual condition visible to true
              currCondition.visible = true;
              
              currConditionName = currCondition.name
              //set pdfName
              var exportTo = File(currFilePath + currFileName + '_' + currConditionName +'.pdf');
              
              //Have a look here:
              //export PDF. to choose backgroundexport. use the second line of code
              currDoc.exportFile(ExportFormat.PDF_TYPE, exportTo,false,  nameOfThePDFExportPresetYouWantToUse);
              //currDoc.asynchronousExportFile(ExportFormat.PDF_TYPE, exportTo,false,  nameOfThePDFExportPresetYouWantToUse);
              
              
              //set actual condition visible to false
                  currCondition.visible = false;
                  }
              
              
              Sunny Day 
              
              Hans-Gerd Claßen
              
              • 4. Re: A Script for Conditional Text Batch Export
                yoitsrobj Level 1

                Excellent! Thanks!

                • 5. Re: A Script for Conditional Text Batch Export
                  FeralDB

                  Hi all

                   

                  I wondered if you could help me use this to export interactive PDFs? I'm using InDesign CS6 and it won't let me set a preset for interactive PDFs.

                   

                  I have a doc with various languages in conditional text which I want to be able to export all at once with the following interactive PDF settings:

                   

                  Screen Shot 2014-04-28 at 11.30.22.png

                  Thanks in advance for any help you can offer.