Skip to main content
Participant
July 5, 2008
Question

Export of multiple pdf files, with different ranges ?

  • July 5, 2008
  • 3 replies
  • 521 views
Hello

I am really trying to figure this one out.

I am trying to export several PDF files form one document at once by defining ranges such as:

Page 1 -> 1.pdf
Page 2-3 -> 2.pdf
Page 3 -> 3.pdf
Page 4-6 -> 5.pdf

Does anyone know a batch export-scripting method that can not only export multi-pdf files at once but also work with not just single pages but different ranges ?

Kind regards
Rosberg
This topic has been closed for replies.

3 replies

Loic.Aigon
Legend
July 6, 2008
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.
Loic
Jongware
Community Expert
Community Expert
July 6, 2008
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.
Loic.Aigon
Legend
July 5, 2008
Hi
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;
myFilePath = myFolder + / + myfilename +"_" + myrangearr + .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.
Loic