2 Replies Latest reply on Dec 21, 2014 5:04 AM by cathykka

    Odd Script Issue - Export to Pdf

    cathykka Level 1

      Hi All.

       

      I have a very small page with three text boxes.

      I have a number of small incopy text files I am flowing in.

      I am using the attached script to export as a pdf.

      The script takes the content of the 1, 2, and 3 text box on each page and creates a file name.

      The export works beautifully, EXCEPT for one very annoying little thing.

      The page that contains the first line of every incopy file is not utilizing the script correctly.

       

      ex.

      correct on almost every export = filename-[0]-[2]-[1].pdf

      the page that contains the first line of each place file= filename-[1]-[2]-[0].pdf and it is ignoring all the replace rules.

       

      Any ideas? This is so random I cannot figure out the issue.

       

      main ();
      
      function main() {
      
      var curDoc = app.activeDocument;
      
      
      // loop through all pages
      for ( var i = 0; i < curDoc.pages.length; i++ ) {
          // the current page
          var curPage = curDoc.pages[i];
      
      
      // Page number
          var pName = curPage.name;
      
      
          // controls the loop
          var controller = true;
          // all paragraphs on the current page
      
      var allPages = (curPage.textFrames[1]); {
          var paraName = allPages.contents;
      
      
      var paraString = "-" + paraName.replace( /\s+$/ , "" ).replace( /\s+/g , "-" ).toLowerCase().replace(/\+/, '').replace(/,/g, '');
      
      
      }
      
      
      var allPages2 = (curPage.textFrames[2]); {
          var paraName2 = allPages2.contents;
      
      
      var paraString2 = "-" + paraName2.replace( /\s+$/ , "" ).replace( /\s+/g , "-" ).toLowerCase().replace(/\+/, '').replace(/,/g, '');
      
      
      }
      
      
      var allPages3 = (curPage.textFrames[0]); {
          var paraName3 = allPages3.contents;
      
      
      var paraString3 = "-" + paraName3.replace( /\s+/g , "-" ).toLowerCase().replace(/-/g, '');
      
      
      }
      
      var folderPath = "~/-create/Process/Labels" ;
         {
              var appendix = paraString;
          }
         
          var filePath = folderPath + "/" + curDoc.name.replace(/\.indd$/,"") + paraString3 + paraString2 + paraString + ".pdf";
          var myFile = File( filePath );
          var pdfPreset = "JOYS Labels"; 
      
      
      with (app.pdfExportPreferences) {
        pageRange = curPage.name;  
        viewPDF = false }
      
      
      
        curDoc.exportFile( ExportFormat.PDF_TYPE, myFile, false, pdfPreset );
        } // end for > pages
      
      
      } // end for > main
      
        • 1. Re: Odd Script Issue - Export to Pdf
          Jump_Over Level 5

          Hi,

           

          Your script defect is it presumes textFrames order is frozen.

          I you modified a doc - i.e. removed some box and recreated it - you modified text boxes order as well.

          So pages still looks the same but text box's order is changed and - i.e. - current textFrame[0] is previous textFrames[2]

           

          To see current textFrames order on a specific page - open Layer Panel. It goes from the top to the bottom of list ([0]-[1]-[2])

           

          Your script presumes textFrames order (displayed in Layer Panel) like

          • paraString3 container
          • paraString container
          • paraString2 container


          Check if your wrong export reason is coming from above.

          Moving textFrames up and down (on the layer) you can fix this order as well.


          Jarek

          • 2. Re: Odd Script Issue - Export to Pdf
            cathykka Level 1

            Thank you! Thank you! Jarek that was exactly it. I appreciate your time.