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.activeDocument.exportFile(ExportFormat.pdfType, File(printLoc +"/" + myDocumentName.substr(myDocument.name.indexOf("_") + 1) + ".pdf"), false, myPDFExportPreset);
Hi John-PC S,
I think that should be:
app.pdfExportPreferences.pageRange = PageRange.allPages;
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:
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;