4 Replies Latest reply on Feb 17, 2016 1:27 PM by runew73276507

    Script which substract current page number with two AND export two separate PDF files got a problem

    runew73276507

      Hi,

       

      OBS: InDesign CS3 script!

       

      Ronald63 and Laubender helped me with this script:

       

      // Number to decrement:
      var nDecrement = 2;
      
      // pageNumberStart for a section is only valid, when continueNumbering is set to false
      app.documents[0].sections[0].continueNumbering = false;
      var myCurrentNumber = app.documents[0].sections[0].pageNumberStart;
      
      if(myCurrentNumber>nDecrement+1)
      {
          app.documents[0].sections[0].pageNumberStart = myCurrentNumber - nDecrement
      };
      
      var doc = app.activeDocument; 
      var _PDFExportPreset = app.pdfExportPresets.item('MyDocumentProfile');
      var _DocName = doc.name.replace(/\.indd/, ""); 
      var _EndNumber = parseInt(_DocName.match(/\d{3}$/),10); /* extract end number */
      /* test if is a number */
      if (isNaN(_EndNumber)){
          alert('End document name is not a number');
          exit();
      }
      
      for(i = 0; i < doc.pages.length; i++){ 
          _PageName = doc.pages.item(i).name; 
          app.pdfExportPreferences.pageRange = _PageName;     
          _NewNumber = _EndNumber + i; /* incresase number */
          _NewNumber = ("00"+_NewNumber).slice(-3); /* padding */
          _DocName = _DocName.replace(/\d{3}$/,_NewNumber); /* replace number in doc name */
          _PDFfile = new File('\\\\testserver\\'.concat(_DocName,'.pdf'));
          doc.exportFile(ExportFormat.pdfType, _PDFfile, false, _PDFExportPreset);
      }
      

       

      It got a problem when I have two pages with a frame with content which cross both pages:

      Udklip.PNG

      When I run the script I get this result:

      Udklip.PNG

       

      So an empty page and the frame with content is on the other page outside the PB.

       

      If I delete this part from the script:

      // Number to decrement:
      var nDecrement = 2;
      
      // pageNumberStart for a section is only valid, when continueNumbering is set to false
      app.documents[0].sections[0].continueNumbering = false;
      var myCurrentNumber = app.documents[0].sections[0].pageNumberStart;
      
      if(myCurrentNumber>nDecrement+1)
      {
          app.documents[0].sections[0].pageNumberStart = myCurrentNumber - nDecrement
      };
      

       

      then it works fine

       

      What am I missing?