Adobe InDesign CS2 Scripting Guide
pdfMarkType = 1147563124;
printerMarkWeight = PDFMarkWeight.p125pt;
registrationMarks = true;
try{
simulateOverprint = false;
}
catch(e){}
useDocumentBleedWithPDF = true;
//Set viewPDF to true to open the PDF in Acrobat or Adobe Reader.
viewPDF = false;
}
//Now export the document. You'll have to fill in your own file path.
app.activeDocument.exportFile(ExportFormat.pdfType, File("/c/myTestDocument.pdf"), false);
Exporting a range of pages
The following example shows how to export a specified page range as PDF:
//ExportPageRangeAsPDF.jsx
//an InDesign CS2 JavaScript
//Exports the specified page range as PDF.
//Assumes you have a document open, and that that document
//contains at least 12 pages.
with(app.pdfExportPreferences){
//pageRange can be either PageRange.allPages or a page range string
//(just as you would enter it in the Print or Export PDF dialog box).
pageRange = "1, 3-6, 7, 9-11, 12";
}
var myPDFExportPreset = app.pdfExportPresets.item("prepress")
app.activeDocument.exportFile(ExportFormat.pdfType, File("/c/myTestDocument.pdf"), false,
myPDFExportPreset);
Exporting pages as EPS
When you export a document as EPS, InDesign saves each page of the file as a separate EPS graphic (an EPS,
by definition, can contain only a single page). If you're exporting more than a single page, InDesign appends
the index of the page to the file name. The index of the page in the document is not necessarily the name of
the page (as defined by the section options for the section containing the page).
Exporting all pages
The following script exports the pages of the active document to one or more EPS files:
//ExportAsEPS.jsx
//an InDesign CS2 JavaScript
//Exports the pages of the active document as EPS.
var myFile = new File("/c/myTestFile.eps");
app.activeDocument.exportFile(ExportFormat.epsType, myFile, false);
Exporting a range of pages
To control which pages are exported as EPS, set the pageRange property of the EPS export preferences to a
page range string containing the page or pages that you want to export before exporting:
//ExportSelectedPagesAsEPS.jsx
//An InDesign CS2 JavaScript
//Enter the name of the page you want to export in the following line.
//Note that the page name is not necessarily the index of the page in the
//document (e.g., the first page of a document whose page numbering starts
//with page 21 will be "21", not 1).
Working with Documents in JavaScript
141