3 Replies Latest reply on May 20, 2014 9:49 AM by Peter Stnsz

    PDF export automation




      My company is looking for a way to automate our CD label generation process further than what we have it at now. I was directed over here from the general InDesign community. We are on Windows 7 operating CS6. A couple of folks have CC.


      We have been using a fairly tedious method of exporting our sequentially numbered CD labels by manually changing the disk number on our template and exporting to .pdf one at a time, typically named CD01.pdf, CD02.pdf and so on. Is it possible through scripting (with which I am completely unfamiliar) to export indivual .pdfs that are sequentially named and numbered from one .indd file? All of the info on the disk labels would be the same except for the sequence number on the disk. To put it simply, once the label is created and ready for export, tell InDesign that we have a project that is 11 CDs long,  have InDesign export 11 individual .pdfs, numbered 1 through 11 and then save each to a simple naming convention, like the one mentioned above.


      Here is the link to the conversation that we had going on over in the  general community to maybe better help describe what we're looking for:




      Thanks very much for any help offered!


        • 1. Re: PDF export automation
          Jump_Over Level 5

          Hi Mike,


          try this .jsx code:


              mDoc = app.activeDocument,
              mCopies = prompt ("Input a number of variations","1","How many copies?"),
              copyPath = mDoc.filePath + "/PDF",
              copyFolder = Folder(copyPath),
              mPreset = app.pdfExportPresets.item("CDlabel");
          if (!copyFolder.create() ) exit();
          if (mCopies && Number(mCopies) > 0) 
              mCopies = Number(mCopies);
          else exit();
              mZeroNumber = String(mCopies).length,
              mName, step, currFile;
              // Progress bar -----------------------------------------------------------------------------------
                  progressWin = new Window ("window", "PDF export"),
                  progressBar = progressWin.add ("progressbar", [12, 12, 350, 24], 0, mCopies),
                  progressTxt = progressWin.add("statictext", undefined, "Currently exporting: "),
                  count = 0;
              progressTxt.bounds = [0, 0, 340, 20];
              progressTxt.alignment = "left";
              // Progress bar -----------------------------------------------------------------------------------
          do {
              step = mZeroNumber - String(mCopies).length;
              mName = "CD";
              while ( step-->0)
                  mName += "0";
              mName += mCopies + ".pdf";
              currFile = File(copyPath + "/" + mName);
              // Progress bar -----------------------------------------------------------------------------------
                  progressBar.value = count;
                  progressTxt.text = String("Currently export - " + currFile.displayName);
              // Progress bar -----------------------------------------------------------------------------------
              mDoc.exportFile(ExportFormat.PDF_TYPE, currFile, false, mPreset);
          while (mCopies-->1);
              // Progress bar -----------------------------------------------------------------------------------
              // Progress bar -----------------------------------------------------------------------------------



          1. Your template.indd is opened and saved

          2. Output folder location is set as copyPath (can be modified)

          3. PDF export preset is set as mPreset (can be modified)



          • 2. Re: PDF export automation
            Mike.Campbell Level 1

            Thanks Jarek, will give this a shot and let youknow of the outcome!

            • 3. Re: PDF export automation
              Peter Stnsz

              This works brilliant! I was wondering if can you save the file outside the folder (1 subfolder up) or use?:


              try {
                  FolderRef = FolderRef.selectDlg("Choose a Destination to save your PDF");
                  if (FolderRef != null) {
                      folderResult = true;


              Skipping the number of copies and append text to exported pdf for i.e. file-draft1.pdf ?