Copy link to clipboard
Copied
I have a lot of documents to export to png and pdf (384 documents, basically the same documents, 12 shells and 32 different sales people names). I found the script below but it's not working in Indesign 20.2, and I'm too dumb to edit it. I thought the pdf preset name was the issue, but none seem to work.
In a perfect world, this script would work on all open documents (I generally open 32 at a time), but I think that's pushing it. Any help is appreciated.
var doc = app.activeDocument;
// PDF Export
function exportPDF() {
var pdfExportPath = doc.filePath.parent + "/" + doc.name.split(".")[0] + ".pdf";
doc.exportDocument({
file: new File(pdfExportPath),
exportPDFOptions: {
presetName:"
[PDF/X-4:2008]",
},
});
}
// PNG Export
function exportPNG() {
var pngExportPath = doc.filePath.parent + "/" + doc.name.split(".")[0] + ".png";
doc.exportDocument({
file: new File(pngExportPath),
exportJPEGOptions: {
fileFormat:ExportFileFormat.PNG,
},
});
}
// Call the functions
exportPDF();
exportPNG();
1 Correct answer
I found the script below but it's not working in Indesign 20.2
This script can't work in any version: everything is wrong there.
Here I made a working version. Tested in Indy 19.5 and 20.0.
var doc = app.activeDocument;
var docPathNoExt = doc.fullName.absoluteURI.replace(/\.[^\.]+$/, "");
// PDF Export
function exportPDF() {
var pdfFile = new File(docPathNoExt + ".pdf");
var pdfPreset = app.pdfExportPresets.item("[PDF/X-4:2008]");
doc.exportFile(ExportFormat.PDF_TYPE, pdfFile, false, pdfPreset
...
Copy link to clipboard
Copied
Hi @rickwtexas ,
look into this script by Peter Kahrel:
Batch-process (convert/export/import) documents
by Peter Kahrel, latest version from 21 Jan. 2025
https://creativepro.com/files/kahrel/indesign/batch_convert.html
Regards,
Uwe Laubender
( Adobe Community Expert )
Copy link to clipboard
Copied
thanks. Its in jsxbin format, all the online converters have been taken down (
Copy link to clipboard
Copied
Hi @betsyl1670440 ,
well yes, Peter Kahrel's script is jsxbin format.
Nevertheless you can download the script file and move it to your personal Scripts User folder and start it from there.
Note: I would recommend Peter Kahrel's scripts as "trusted sources".
Regards,
Uwe Laubender
( Adobe Community Expert )
Copy link to clipboard
Copied
Note: I would recommend Peter Kahrel's scripts as "trusted sources".
As long as downloaded from a "trusted source" - creativepro website.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
If you want a paid-for solution, my Extract Pages is quite popular: https://www.id-extras.com/products/extract-pages/
Copy link to clipboard
Copied
If you want a paid-for solution, my Extract Pages is quite popular: https://www.id-extras.com/products/extract-pages/
By Tá´€W
In that case - paid solutions - can I suggest my ID-Tasker tool? But it's Windows only. It will automatically process any number of files - including subfolders.
Copy link to clipboard
Copied
I found the script below but it's not working in Indesign 20.2
This script can't work in any version: everything is wrong there.
Here I made a working version. Tested in Indy 19.5 and 20.0.
var doc = app.activeDocument;
var docPathNoExt = doc.fullName.absoluteURI.replace(/\.[^\.]+$/, "");
// PDF Export
function exportPDF() {
var pdfFile = new File(docPathNoExt + ".pdf");
var pdfPreset = app.pdfExportPresets.item("[PDF/X-4:2008]");
doc.exportFile(ExportFormat.PDF_TYPE, pdfFile, false, pdfPreset);
}
// PNG Export
function exportPNG() {
var pngExportPrefs = app.pngExportPreferences;
with (pngExportPrefs) {
pngQuality = PNGQualityEnum.MAXIMUM;
transparentBackground = true;
exportResolution = 72;
pngExportRange = PNGExportRangeEnum.EXPORT_ALL;
pngSuffix = "_page_^P";
}
var pngFile = new File(docPathNoExt + ".png");
doc.exportFile(ExportFormat.PNG_FORMAT, pngFile, false);
}
// Call the functions
exportPDF();
exportPNG();
Change PNG export prefs to whatever you need.
In a perfect world, this script would work on all open documents (I generally open 32 at a time), but I think that's pushing it. Any help is appreciated.
It's possible with my Batch processor script. You can process all files in one go, running them through all folders and subfolders.
Copy link to clipboard
Copied
THANK YOU! Full disclosure - I've already exported all these files manually 3 times. Client likes to make changes after they say everything is approved.
Copy link to clipboard
Copied
To all:
regarding scripting and there the Folder object with InDesign 2025 version 20.1 (perhaps also above) there is a bug that could hurt. Read this article by Marc Autret:
The Great Folder Fiasco: A Tale of InDesign 20.1 and macOS
Marc Autret, January 31, 2025 | Snippets | en
https://indiscripts.com/post/2025/01/the-great-folder-fiasco
Regards,
Uwe Laubender
( Adobe Community Expert )
Copy link to clipboard
Copied
Copy link to clipboard
Copied
FWIW:
Well, the Folder object bug should be fixed with InDesign 2025 version 20.2.0.36.
Had no chance to test it, because my InDesign 2025 is constantly crashing when I click the View menu in the GUI.
( with or without a document open )
Will try a new, clean install.
Regards,
Uwe Laubender
( Adobe Community Expert )

