Article View: adobe.scripting.indesign
Article #15917InDesign CS--ExportEachPageAsPDF
From: Olav_Kvern
Date: Mon, 03 Nov 2003 21:07
Date: Mon, 03 Nov 2003 21:07
51 lines
2618 bytes
2618 bytes
Gang--
Every now and then, I've been asked how to export each page of an InDesign document as a separate PDF. I think this is usually used for input for an imposition system. Here's an InDesign CS JavaScript that does the trick:
//ExportEachPageAsPDF.js
//An InDesign CS JavaScript.
//Exports each page of an InDesign CS document as a separate PDF to a selected folder.
//Display a "choose folder" dialog box.
if(app.documents.length != 0){
var myFolder = Folder.selectDialog ("Choose a Folder");
if(myFolder != null){
myExportPages(myFolder);
}
}
else{
alert("Please open a document and try again.");
}
function myExportPages(myFolder){
var myDocument = app.activeDocument;
var myDocumentName = myDocument.name;
var myDialog = app.dialogs.add();
with(myDialog.dialogColumns.add().dialogRows.add()){
staticTexts.add({staticLabel:"Base name:"});
var myBaseNameField = textEditboxes.add({editContents:myDocumentName, minWidth:160});
}
var myResult = myDialog.show({name:"ExportPages});
if(myResult == true){
//The name of the exported files will be the base name + the value of the counter + ".pdf".
var myBaseName = myBaseNameField.editContents;
//Remove the dialog box from memory.
myDialog.destroy();
for(var myCounter = 0; myCounter<myDocument.pages.length; myCounter++){
app.pdfExportPreferences.pageRange = (myCounter+1) + "";
//Generate a file path from the folder name, the base document name, and the counter value.
var myFilePath = myFolder + "/" + myBaseName + (myCounter+1) + ".pdf";
var myFile = new File(myFilePath);
app.activeDocument.exportFile(ExportFormat.pdfType, myFile, false);
}
}
else{
myDialog.destroy();
}
}
Save the script as a text file with the file extension ".js" and put it--or an alias/shortcut to it--in the Scripts folder in the Presets folder inside your InDesign folder. Run the script from the Scripts palette.
Thanks,
Ole
Technical Details
Message-ID:
<2cce29f6.-1@webx.la2eafNXanI>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.tpinternet.pl!newsfeed01.sul.t-online.de!t-online.de!webxShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f939a,9c083dcfc7f476d3,start X-Google-Attributes: gidf939a,public X-Google-ArrivalTime: 2003-11-03 13:08:15 PST From: Olav_Kvern@adobeforums.com Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.tpinternet.pl!newsfeed01.sul.t-online.de!t-online.de!webx Newsgroups: adobe.scripting.indesign Subject: InDesign CS--ExportEachPageAsPDF Message-ID: <2cce29f6.-1@webx.la2eafNXanI> Date: Mon, 3 Nov 2003 13:07:09 -0800 Lines: 59 MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit