Skip to main content
secklund
Participating Frequently
January 2, 2020
Answered

InDesign script to batch export png, jpg or pdf

  • January 2, 2020
  • 2 replies
  • 11383 views

I'm looking for a script that can export png's or jpgs or pdf's. Anything that can be viewed without having indesign on your computer. Does anyone know of one? I've tried the batch export script from Peter Kahrel and it doesn't quite work for me as it takes about 3 minutes per document. Is there anything else that can accomplish this faster? I tried bridge, but the jpgs it exports are tiny for some reason. Can't figure it out.

 

Thanks in advance!

Scott

This topic has been closed for replies.
Correct answer brian_p_dts

Yeah it has the same dialogue box as it did before asking about missing links.


Right, I guess that's a popup when you open a doc, not a preflight thing.

 

After the var folder selectDialog line, you can try the following lines: 

 

     var currInteractPrefs = app.scriptPreferences.userInteractionLevel;

     app.scriptPreferences.userInteractionLevel = UserInteractionLevels.NEVER_INTERACT;

 

At the end of the script, be sure to set the prefs back to the way they were: 

      app.scriptPreferences.userInteractionLevel = currInteractPrefs;

 
Not sure if that will work or if it will just hang the script, but worth a shot. Otherwise, I got nothin'. 

2 replies

Participant
February 28, 2022

Hi All, 

Where or who can I buy a script from that does batch Package of InDesign files and creates a PDF & JPEG or whatever other format I need?
Thanks
Dean

Participant
July 21, 2022
brian_p_dts
Community Expert
Community Expert
January 3, 2020

I mean, if you just want to export all open documents as pdfs with no extra fuss, this would work. The time it takes would be dependent on the complexity of the file to export, just as if it were done manually. This assumes your ID has the PDF/x1a preset loaded. 

 

 

 

var outputToPdf = function(doc, folder) {
    var exportFile = new File(folder.fsName + "/" + doc.name.slice(0,doc.name.lastIndexOf(".")) + ".pdf");
    var px1aPreset = app.pdfExportPresets.itemByName("[PDF/X-1a:2001]");
    try {
        doc.exportFile(ExportFormat.PDF_TYPE, exportFile, false, px1aPreset);
    } catch(e) {
        alert("Couldn't export " + exportFile.name + " for this reason: " + e);
    }
};

var folder = Folder.selectDialog("Please select a folder to save to");
var docs = app.documents;
for (var i = 0; i < docs.length; i++) {
    outputToPdf(docs[i], folder);
}

 

 

  

secklund
secklundAuthor
Participating Frequently
January 3, 2020

Hmm. I'm getting a javascript error. "documents not defined." Any idea on a quick fix?

secklund
secklundAuthor
Participating Frequently
January 3, 2020

That's what I get for not actually testing 🙂 

 

Try the edited code now. 


You're the man Brian!

Do you know if there is a way to do this to a whole directory of files?

 

Would something like this work with this script? This is for a different script that packages all files within a folder structure.

 

 

var myFolder = Folder.selectDialog("Select a folder with INDD files to package");
if (myFolder == null) exit();
var myFilelist = [];
var myAllFilesList = myFolder.getFiles();

for (var f = 0; f < myAllFilesList.length; f++) {
	var myFile = myAllFilesList[f];
	if (myFile instanceof File && myFile.name.match(/\.indd$/i)) {
		myFilelist.push(myFile);
	}
}

if (myFilelist.length == 0) {
	alert("No files to open.", "Package for  Aprimo");
	exit();
}