This website contains various projects I have worked on. Currently, this includes JavaScripts for Adobe applications and general produciton tutorials using Adobe Creative Suite applications. All projects can be accessed from the right-hand menu.

image of a notepad
Batch PDFs from InDesign CS3

Script Description

Let’s say you have a batch of InDesign files and you want to convert them all to PDFs quickly. Here’s and easy way to do just that using a PDF preset and some JavaScript.

Looking at the script

The script starts out by creating two variables. One for the PDF preset to use, and the other for the location of the folder containing the InDesign files. Change the text between the quotes "myPDFpreset" to the name of the PDF preset that you want the script to use. I get the location of the files by using the method “selectDialog ” of the object “Folder ”.

//==== Batch PDF =====\\
/* InDesign JavaScript to Create PDFs of a batch of InDesign files using an export PDF preset */

var myPDFExportPreset = app.pdfExportPresets.item("myPDFpreset");
var myFileLocation = Folder.selectDialog("Please select path to files");
								

Next I create a new folder object with the location that the user selected from the dialog box. I search through this folder for all files that end in .indd. I create an array containing all the files found. I then set a variable equal to the size of the array(minus one).

myFolder = new Folder ([myFileLocation]);
myFolderContents = myFolder.getFiles("*.indd"); // array
myFileAmount = (myFolderContents.length - 1); 
								

Now for the fun part. I create a loop that will perform three tasks for each file found in the selected folder. First it will open the file. Second it will export a PDF of the file. And third, it will close the file. When I export the file I set a few parameters that can be found between the paranthesis and are seperated by commas. “ExportFormat” is set to PDF. “File” stores the name the pdf will be saved as. This is done be finding the name of open InDesign file(including the path to the file) and replacing the .indd with .pdf. The “false” parameter is so that the save options dialog box does not appear. And the last parameter is the myPDFExportPreset variable containing the PDF preset.

// ===== Open, Export as PDF, and Close files ===== \\ 
for (i = myFileAmount; i >= 0; i--)
{ 
	app.open(File (myFolderContents[i]));
	app.activeDocument.exportFile(
		ExportFormat.pdfType, 
		File(myFolder.fsName + "/" + app.activeDocument.name.split(".indd")[0] + ".pdf"),
		false, 
		myPDFExportPreset
		);
	app.activeDocument.close(SaveOptions.no);
}
								

back to top

Image of a notepad

Table-of-contents

Script files


Other Projects:

Adobe JavaScripts ↑↓

Adobe Creative Suite Tutorials ↑↓



Do you ever make PDFs of your InDesign files in batches?

Yes.
No.
I do now!