2 Replies Latest reply on Feb 18, 2011 2:49 AM by Smart_77

    Data Merge export to single pdf and auto naming

    Smart_77 Level 1

      Hi All,

       

      I have a question that I have been searching for the answer on here for a few hours...

       

      I am needing to make up around 200 certificates

       

      Each certificate will have 3 text boxes, Im using Data merge to fill these fields.

       

      My question has 2 parts:

       

      Part 1 of my question is -  What script can I use to export these 200 certificates to seperate pdfs

       

      Part 2 of my question is - What script can I utilise to make use of one of the fields which will be (name) and use that to name the file when it is exported?

       

      Much appreciated...

       

      Darren.

        • 1. Re: Data Merge export to single pdf and auto naming
          Loic.Aigon Adobe Community Professional

          Hi,

           

          You may want to try two scripts I wrote :

           

          Export single PDFs file :

          http://www.scriptopedia.org/index.php?post/custompdfexport.jsx.html

           

          use some csv row to rename a bunch of pdf files accordingly:

          var csv=File(Folder.desktop+"/fichier.csv");
          
          var myPDFFolder = Folder(Folder.desktop+"/pdfs");
          
          var names = getNamesFromCSV(csv);
          
          if(csv.exists && myPDFFolder.exists){
              var files = myPDFFolder.getFiles();
              if(files.length==names.length){
                  for(var i=0; i<files.length; i++){
                      files[i].rename(files[i].parent+"/"+names[i]+".pdf");
                  }
              }
          }
                  
          function getNamesFromCSV(csv){
              if(csv.exists){
                  csv.open('r');
                  var content = csv.read();
                  var namesArr = [];
                  content=content.split("\n");
                  for(var j=0; j<content.length; j++){
                      namesArr.push(content[j].match(/^(.[^\n]+)/i)[1]);
                  }
                      
                  csv.close();
                  return namesArr.slice(1,namesArr.length);
              }
              return false;
          }
          

          This code was intented to use the first row item as the basis for renaming the PDF files. Adapt it to your own needs.

           

          Hope it helps,

           

          Loic

          http://www.loicaigon.com

          http://www.scriptopedia.org