This content has been marked as final. Show 3 replies
Your request is really simple.
The only "difficulty" is to repeat the Export function through a loop for the number of export ranges you want to specify.
The range itself may be determined in the PDF export preferences.
var myrangearr = ["1","2-3","3","4-6"];
var myFolder = Folder.selectDlg();
var myPDFExportPreset = "High Quality"; //May match one of your PDF presets name !
//Or a directory you already know or better the folder containing the genuine file.
for(var i = 0; i < myrangearr.length; i++)
app.pdfExportPreferences.pageRange = myrangearr[i];
myFilePath = myFolder + / + myfilename +"_" + myrangearr[i] + .pdf;
myFile = new File(myFilePath);
myDocument.exportFile(ExportFormat.pdfType, myFile, false, myPDFExportPreset);
If you take time to specify correctly the export folder and myPDFExportPreset, it should do the trick.
You could put the number of pages as a label into the first page of each set, i.e., in page 1 put "1", in page 2, "2", in page 4, "1" etc.
Then loop over all pages, exporting the ones with a page label, with the number of pages in that same label.
Advantage: you can insert and remove any set at will, and it'll work just fine. The array in Loic's script is fixed.
Disadvantage: you need another script to set the page labels (can't do that in the UI -- but it's a real easy script); and you should be careful removing and inserting pages at the right places, not in the middle of an existing set.
I am quite fond of dialog box for this kind of purposes.
A single prompt does the trick.
var myrangeinput = prompt ("Enter a range of page separated by commas.","", "page range PDF exporter");
var myrangearr = new Array();
myrangearr = myrangeinput.split(",");
At this point a control loop may be useful to ensure that pages ranges are valid, otherwise the script will fail.
Will think about that tommorow.