4 Replies Latest reply on Dec 12, 2008 4:22 AM by Loic.Aigon

    Data Merge Help!  Naming Help, is it possible??

    Level 1
      Hello, I am using the data merge system in Indesign to create 300 customized documents (each document is for a different company)

      When the data merge is complete I will be left with a 600 page INDD file (each customized document will be 2 pages)which is totally fine because I have a script that will export every two pages to PDF. (which is what I need as a final product, 300 2-page documents)

      But my problems is this, I need to name each of the 300 documents by the company it corresponds to, is there a script out there that can export every two pages to PDF(kind of like the one I have now), but then link the naming system to the "Company Name" data field (the one linking to my .CSV file)?

      I would LOVE to not have to rename all 300 manually.

      Any help would be GREATLY appreciated. And please let me know if you need any more information

      Thank you, Kevin
        • 1. Re: Data Merge Help!  Naming Help, is it possible??
          Do you import the name into the template? If so then yes you can.

          Off the top of my head, something like this in JS...

          myDoc = app.activeDocument;
          var myCompanyName = myDoc.textFrames.item("companyName"); //you'll have to put a script label on this frame.
          var myNewName = myCompanyName.contents;
          var myPDFExportPreset = app.pdfExportPresets.item("myPreset"); //this is the best way to export to PDF IMO.
          var newFileName = myNewName + ".pdf"; //this line adds the company name to the file name.
          myDoc.exportFile(ExportFormat.pdfType, File(newFileName), false, myPDFExportPreset);

          Let me know how you go.

          • 2. Re: Data Merge Help!  Naming Help, is it possible??
            Level 1
            yeah it goes like this, I create a text frame, and I link the column in my .csv file called "company name" to that text frame, then hit data merge.  and boom, 600 page document every other page has the customized company name.  <br /><br />Only I really dont know much about writing Script, I have a script that someone gave me and here it is.  <br /><br />ad = app.activeDocument; <br />pg=ad.pages; <br />var docpath = ad.filePath; <br />var docname = ad.name; <br />var nb = (Math.round(Number(pg.length/2))) <br />for(i=0; i<nb;i++) <br /><br />{ <br /><br />var pgrgstart = (pg[(2*i)].name); <br />if(pg[(2*i+1)]==-1) <br />{ <br />var pgrgend = pgrgstart; <br />var P = ""; <br />} <br />else <br />{ <br />var pgrgend = pg[(2*i+1)].name; <br />var P = "_to_"+(i+1); <br />} <br />app.pdfExportPreferences.pageRange = pgrgstart+"-"+pgrgend; <br />var myPDFExportPreset = app.pdfExportPresets.item("kevintest"); <br />//enter the name of your PDF preset instead of your PDF preset <br />ad.exportFile(ExportFormat.pdfType, File(docpath+"/"+docname.split(".indd")[0]+"_"+"pg_"+i+P+".pdf"), false, myPDFExportPreset); <br />} <br /><br />This exports every other page from my file so I wind up with 300 2-page PDFs pefectly.  <br /><br />Do you know of a way to name each PDF based on the text frame that is being merged(so that I may end up with the "Company name" in the name of the PDF), instead of docpath+"/"+docname.split(".indd")[0]+"_"+"pg_"+i+P+".pdf" <br /><br />What if I put the merged text frame on its own layer? <br /><br />I am sorry I wish I knew more about JS, and I really want to learn.  <br /><br />Thank you very much for your help,<br />Kevin
            • 3. Re: Data Merge Help!  Naming Help, is it possible??
              I got a similar Problem. I got a 200 page InDesign Document and want to save each page as a InDesign-Document or PDF-File. The Filename has to be generated from a labeled textframe. Can someone please post a script which does this, I'm a newbie in scripting and need this script urgently :-(
              • 4. Re: Data Merge Help!  Naming Help, is it possible??
                Loic.Aigon Adobe Community Professional
                replace that :

                b ad.exportFile(ExportFormat.pdfType, File(docpath+"/"+docname.split(".indd")[0]+"_"+"pg_"+i+P+".pdf"), false, myPDFExportPreset);

                by that :
                //Assuming you have a labelled textFrame "co";
                //You can label a textFrame by selectionning it in the ui and then use the script palette, label toggle > enter a string such as co in the field.

                b var co = pg[i].textFrames.item("co").contents;

                b ad.exportFile(ExportFormat.pdfType, File(docpath+"/"+docname.split(".indd")[0]+"_"+co+".pdf"), false, myPDFExportPreset);

                PS: someone is Loic :-)