15 Replies Latest reply on Feb 5, 2014 4:10 AM by Colin Flashman

    Exporting a 6 pg document and changing a text frame on 1st and 6th page for each 50 times

    yvesha Level 1

      I have these 6 page brochures and there are 50 marketing codes which need to be on first and 6th pages (different codes for each document exported). Rather than manually changing the marketing codes on the 2 pages 50 times (which takes too long) there has to be a easy way to do it. Anyone came across this?

        • 1. Re: Exporting a 6 pg document and changing a text frame on 1st and 6th page for each 50 times
          Colin Flashman Adobe Community Professional

          I would use InDesign's Data Merge palette to do this. This tutorial may help: http://www.youtube.com/watch?v=ktcbTtC3-Xk

          • 2. Re: Exporting a 6 pg document and changing a text frame on 1st and 6th page for each 50 times
            yvesha Level 1

            Thanks for that. Do you know if there is any way I can export these 50 individual documents to a PDF? rather than how data merge will bring into a new indesign file.

            • 3. Re: Exporting a 6 pg document and changing a text frame on 1st and 6th page for each 50 times
              Colin Flashman Adobe Community Professional

              From the data merge panel, instead of selecting "Create Merged Document", select the option "Export to PDF".

               

              It will merge all the results into one combined PDF.

               

              To merge the files into single page PDFs is something the software can't do by default but I have written a piece about it elsewhere: http://colecandoo.wordpress.com/2013/07/13/breaking-up-is-hard-to-do-indesign-files-into-i ndividual-pdfs-that-is/

              • 5. Re: Exporting a 6 pg document and changing a text frame on 1st and 6th page for each 50 times
                yvesha Level 1

                Hi cdflash,

                 

                Thank you for the wordpress link you gave me, very helpful.

                 

                I was just wondering if you knew if solution one - Loic Aigon's script PDF Export Cropper and Custom Export can be found elsewhere as you link you provided seemed to not work.

                 

                Thanks again.

                • 6. Re: Exporting a 6 pg document and changing a text frame on 1st and 6th page for each 50 times
                  yvesha Level 1

                  and also just wondering if you have to pay to get the action wizard on acrobat. Thanks

                  • 7. Re: Exporting a 6 pg document and changing a text frame on 1st and 6th page for each 50 times
                    Colin Flashman Adobe Community Professional

                    OK, will answer both questions in this post. According to this post http://www.loicaigon.com/en/script-debugging-call-files/ on Loic's blog, it would appear that Loic is in the process of updating several scripts and it just so happens that the PDF export cropper is possibly one of them. Loic has a contact page and as he is the author of the scripts, would be the best contact.

                     

                    Concerning Action wizard, it is a feature of the full version of Acrobat (e.g. not the Reader version) since Acrobat X. Have noticed in Acrobat XI that some actions made previously in Acrobat X didn't migrate to Acrobat XI when updated, and when trying to migrate the scripts, had some difficulties that meant some actions had to be made from scratch.

                    1 person found this helpful
                    • 8. Re: Exporting a 6 pg document and changing a text frame on 1st and 6th page for each 50 times
                      yvesha Level 1

                      Hoping you can help me again cdflash, Thanks for all your wonderful guidance.

                       

                      I am still looking for a method which works for me. Wondering if you can help.

                       

                      I have this script which is below which I need to split a 300 page document which I need to split into 50 documents and name them with a csv file provided. I have the excel spreadsheet with column headed "filename" with 50 file names.

                       

                      When I select the data file to import after being asked to enter text at start of filename etc I see the message 'No filenames found - using "file-XX.pdf". Press Escape after continuing to cancel.'

                       

                      and then the error -

                       

                      RaiseError: The file may be read-only, or another user may have it open. Please save the document with a different name or in a different folder.

                      Doc.extractPages:83:Console undefined:Exec

                      ===> The file may be read-only, or another user may have it open. Please save the document with a different name or in a different folder.

                      file-0

                       

                      I have checked the number of rows in the csv with the one which i created the merge in Indesign and it is the same. I have also tried using google docs spreadsheet but acrobat doesnt recognise the URL.

                       

                      Thanks again.

                       

                      script I am using -

                       

                      var CSV = function (data, delimiter) {

                          var _data = CSVToArray(data, delimiter);

                          var _head = _data.shift();

                          return {

                              length: function () {return _data.length;},

                              adjustedLength: function () {return _data.length - 1;},

                              getRow: function (row) {return _data[row];},

                              getRowAndColumn: function (row, col) {

                                  if (typeof col !== "string") {

                                      return _data[row][col];

                                  } else {

                                      col = col.toLowerCase();

                                      for (var i in _head) {

                                          if (_head[i].toLowerCase() === col) {

                                              return _data[row][i];

                                          }

                                      }

                                  }

                              }

                          };

                      };

                       

                      function CSVToArray( strData, strDelimiter ){

                          strDelimiter = (strDelimiter || ",");

                          var objPattern = new RegExp(

                              (

                                  // Delimiters.

                                  "(\\" + strDelimiter + "|\\r?\\n|\\r|^)" +

                                  // Quoted fields.

                                  "(?:\"([^\"]*(?:\"\"[^\"]*)*)\"|" +

                                  // Standard fields.

                                  "([^\"\\" + strDelimiter + "\\r\\n]*))"

                              ),

                              "gi"

                              );

                       

                          var arrData = [[]];

                          var arrMatches = null;

                          while (arrMatches = objPattern.exec( strData )){

                              var strMatchedDelimiter = arrMatches[ 1 ];

                              if (

                                  strMatchedDelimiter.length &&

                                  (strMatchedDelimiter != strDelimiter)

                                  ){

                                  arrData.push( [] );

                              }

                              if (arrMatches[ 2 ]){

                                  var strMatchedValue = arrMatches[ 2 ].replace(

                                      new RegExp( "\"\"", "g" ),

                                      "\""

                                      );

                              } else {

                                  var strMatchedValue = arrMatches[ 3 ];

                              }

                              arrData[ arrData.length - 1 ].push( strMatchedValue );

                          }

                          return( arrData );

                      }

                       

                      function isInt(n) {

                          return typeof n === "number" && n % 1 == 0;

                      }

                       

                      var prepend = app.response("Enter any text to go at the START of each filename:");

                      var append = app.response("Enter any text to go at the END of each filename:");

                      var pathStr = app.response("If the PDFs should be saved in a sub folder, enter the relative path here:", "", "pdf/");

                       

                      this.importDataObject("CSV Data");

                      var dataObject = this.getDataObjectContents("CSV Data");

                      var csvData = new CSV(util.stringFromStream(dataObject, 'utf-8'), ',');

                      var pagesPerRecord = this.numPages / csvData.length();

                      if (isInt(pagesPerRecord)) {

                          for (var i = 0; i < this.numPages; i ++) {

                              var pageStart = i*pagesPerRecord;

                              var pageEnd = (i+1)*pagesPerRecord - 1;

                              var recordIndex = (i + pagesPerRecord) / pagesPerRecord;

                              var filename = csvData.getRowAndColumn(i, "filename");

                              if (!filename) {

                                  app.alert('No filenames found - using "file-XX.pdf". Press Escape after continuing to cancel.');

                                  filename = "file-" + i;

                              }

                              var settings = {nStart: pageStart, nEnd: pageEnd, cPath: pathStr+prepend+filename+append+'.pdf'};

                              this.extractPages(settings);

                          }

                      } else {

                          var message = "The number of pages per row is not an integer (" + pagesPerRecord;

                          message += ", " + this.numPages + " pages, " + csvData.length() + " rows).";

                      }

                      • 9. Re: Exporting a 6 pg document and changing a text frame on 1st and 6th page for each 50 times
                        Colin Flashman Adobe Community Professional

                        I think this solution is being horribly over-engineered. I also don't know  how to fix the script above in this circumstance. Instead, I would like to go back to the opening post and read the brief:

                         

                        I have these 6 page brochures and there are 50 marketing codes which need to be on first and 6th pages (different codes for each document exported). Rather than manually changing the marketing codes on the 2 pages 50 times (which takes too long) there has to be a easy way to do it. Anyone came across this?

                         

                        This is how I would approach that brief:

                        1. Create a six page document with the necessary static art (the stuff that doesn't change).
                        2. Use the data merge feature of indesign to add the variable art (the stuff that does change) from a text file exported from Excel (for example) that contains the components that change.
                        3. Export the results to one complete PDF file. 50 records with 6pp per record will yield a 300 page PDF file.
                        4. In Adobe Acrobat, use the split documents feature  to break the 300 page file into 6pp sections. If working with Acrobat 9 or up, the split documents feature is there and in the link posted in my earlier post here (http://colecandoo.wordpress.com/2013/07/13/breaking-up-is-hard-to-do-indesign-files-into-i ndividual-pdfs-that-is/) there is a screengrab that demonstrates how it can be used (it is the second set of screen-grabs in the blog).

                        That will make 50 files 6pp long. What it will not do is give the files unique names based on names in the database, but instead preserve the initial filename but with a number suffix attached. Unique names for the PDFs were not requested in the brief.

                        I hope this helps.

                         

                        Message was edited by: cdflash - realised the script being referenced was from a much older post. I didn't know this in my original reply.

                        • 10. Re: Exporting a 6 pg document and changing a text frame on 1st and 6th page for each 50 times
                          yvesha Level 1

                          I tried the following script which you mentioned in that post http://forums.adobe.com/message/4633533#4633533, It gives me the error 'Number of pages & CSV row count inconsistent'. And then shows the codes which I want as my filenames. The number of rows in my csv which I first used for the initial data merge in Indesign and the csv 'PartnerHQ_Id' are the same, not sure why it is not working.

                           

                          Thanks agian for all your help.

                           

                          }0 PartnerHQ_Id'

                          1 D

                          2 E

                          3 ED

                          4 I

                          5 M

                          6 P

                          7 Q

                          8 W

                          9 Z

                          10 SM

                          1

                           

                           

                          /* Put script title here */
                          var CSV = function(data) {
                              var _data = data.split('\r');

                              for(var i in _data) {
                                  if(_data[i].length > 0) {
                                      console.println(i + ' ' + _data[i]);
                                      _data[i] = _data[i].split(',');
                                  }
                              }
                             
                              var _head = _data.shift();

                              return {
                                  length: function() {
                                      return _data.length - 1;
                                  },
                                  getRow: function(row) {
                                      return _data[row];
                                  },
                                  getRowAndColumn: function(row, col) {
                                      if(typeof col !== 'string') {
                                          return _data[row][col];
                                      } else {
                                          col = col.toLowerCase();
                                          for(var i in _head) {
                                              if(_head[i].toLowerCase() === col) {
                                                  return _data[row][i];
                                              }
                                          }
                                         
                                      }
                                  }
                              };
                          };

                          this.importDataObject("CSV Data");
                          var dataObject = this.getDataObjectContents("CSV Data");

                          var csvData = new CSV(util.stringFromStream(dataObject));

                          if(this.numPages != csvData.length()) {
                              app.alert("Number of pages & CSV row count inconsistent");
                          } else {
                              for(var i = 0; i < this.numPages; i++) {
                                  this.extractPages({nStart: i, cPath: csvData.getRowAndColumn(i, 'PartnerHQ_Id') + '.pdf'});
                              }
                          }

                          • 11. Re: Exporting a 6 pg document and changing a text frame on 1st and 6th page for each 50 times
                            Colin Flashman Adobe Community Professional

                            After I posted my last comment I then realised the script that was being referenced. However, I am not the author of that script; poster number 8 of that thread (GrahamHe) is and they would be the person to ask. Another poster (alanomaly) then put their own take on the script.

                             

                            Concerning why the script does not work, I am afraid that I personally do not know the answer.

                             

                            The script is also misfiled. This is an Adobe Acrobat script and any discussion about it really should take place in the Acrobat forums. Apart from the housekeeping issue, it is more likely to be viewed by scripters experienced in Adobe Acrobat than it would in this forum that is for scripting Adobe InDesign.

                             

                            All of this aside, I have to say again that this is not the way I would approach the issue. To answer the brief of creating 50x6pp PDFs that have the same information with the exception of marketing codes on two pages, please try the procedure that I posted in post 9 of this thread.

                            • 12. Re: Exporting a 6 pg document and changing a text frame on 1st and 6th page for each 50 times
                              yvesha Level 1

                              Thanks. Regarding the procedure that you have posted, how do you recommend placing the script into action wizard?

                               

                              I tried saving the script but an error came up saying that it was created in an older system.

                               

                              Thanks again.

                              • 13. Re: Exporting a 6 pg document and changing a text frame on 1st and 6th page for each 50 times
                                Colin Flashman Adobe Community Professional

                                My ONLY recommendation that will do what is asked of the original brief is to follow my instructions as pointed out in post 9 of this thread.

                                 

                                Using those instructions only, it is not necessary to use a script at all. All requests are handled by the software without any scripting required.

                                • 14. Re: Exporting a 6 pg document and changing a text frame on 1st and 6th page for each 50 times
                                  yvesha Level 1

                                  Thank you for your reply.

                                   

                                  I have done all steps which you mentioned in post 9, but it still takes time re naming the individual files after the data merge. As I have 50 brochures which I have to individually name on a daily basis it would be extremely handy to get a script that worked to do this for me.

                                  • 15. Re: Exporting a 6 pg document and changing a text frame on 1st and 6th page for each 50 times
                                    Colin Flashman Adobe Community Professional

                                    Now I understand what is going on. However, that was not spelled out in the opening post or subsequent posts that the PDF names had to be unique.

                                     

                                    However, there are numerous ways to rename a collection of files based on an excel spreadsheet. Google search the term "rename files based on excel list" and a variety of solutions are presented to rename the files. Not sure if you are using Mac or Windows but there should be a solution amongst the results of that search.

                                     

                                    I hope this helps.