2 Replies Latest reply on Jul 13, 2011 8:09 AM by [Jongware]

    Problems with pageRange.allPages reliability...

    John-PCS

      Fair warning: I'm fairly new to this.

       

      For some reason the code below isn't reliably exporting pages. My 4 page documents are set up as two sets of facing 8.5x11s (I'm creating spreads from pages 1-2 and 3-4). When I first run this script on a 4 page document, it will usually only export the first spread, pages 1 and 2. But then if I reopen the doc and run it again, it'll export both spreads, all 4 pages, 95% of the time. What have I done wrong to make this code so unreliable? Is there a particular reason that pageRange.allPages doesn't reliably export all pages? I'm having a hard time believing that it's the preset, but I could be wrong.

       

      //Send To Print
      var myPDFExportPreset = app.pdfExportPresets.item("TO-PRINT");
      app.pdfExportPreferences.pageRange.allPages;
      app.activeDocument.exportFile(ExportFormat.pdfType, File(printLoc +"/" + myDocumentName.substr(myDocument.name.indexOf("_") + 1) + ".pdf"), false, myPDFExportPreset);

       

      Thanks!

        • 1. Re: Problems with pageRange.allPages reliability...
          Olav Kvern Level 1

          Hi John-PC S,

           

          I think that should be:

           

          app.pdfExportPreferences.pageRange = PageRange.allPages;

           

          Thanks,

           

          Ole

          • 2. Re: Problems with pageRange.allPages reliability...
            [Jongware] Most Valuable Participant

            John-PCS wrote:

             

            Is there a particular reason that pageRange.allPages doesn't reliably export all pages? I'm having a hard time believing that it's the preset, but I could be wrong.

             

            You are wrong

             

            The problem, however, lies not where you think but somewhere else. Is your post copied out of the script you are using? Then the problem is this line:

             

            app.pdfExportPreferences.pageRange.allPages;
            

             

            You are attempting to set a property ("pageRange") in the PDF Export Preferences by just calling out its name. The "allPages" right after it is a syntax error in any other language, but Javascript allows it. It still doesn't do anything.

            Effectively, you never change the "latest" setting of the page range box, so what you get is what you used last time. Embarressed looks all around.

             

            Try this instead:

             

            app.pdfExportPreferences.pageRange = PageRange.ALL_PAGES;