Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
0

Anyone have a script to export pdf and png at same time?

Participant ,
Mar 12, 2025 Mar 12, 2025

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();

TOPICS
Import and export , Scripting
169
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Guru , Mar 13, 2025 Mar 13, 2025

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
...
Translate
Community Expert ,
Mar 12, 2025 Mar 12, 2025

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 )

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Mar 12, 2025 Mar 12, 2025

thanks. Its in jsxbin format, all the online converters have been taken down (

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 13, 2025 Mar 13, 2025

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 )

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 13, 2025 Mar 13, 2025
quote

Note: I would recommend Peter Kahrel's scripts as "trusted sources".

 

As long as downloaded from a "trusted source" - creativepro website. 

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 12, 2025 Mar 12, 2025

@rickwtexas

 

What error do you get? 

 

Is it ChatGPT generated? 

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Mar 12, 2025 Mar 12, 2025

If you want a paid-for solution, my Extract Pages is quite popular: https://www.id-extras.com/products/extract-pages/

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 12, 2025 Mar 12, 2025
quote

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.

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Mar 13, 2025 Mar 13, 2025

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.

KasyanServetsky_1-1741855407018.pngexpand image

KasyanServetsky_2-1741855478978.pngexpand image

 

 

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Mar 13, 2025 Mar 13, 2025

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. 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 13, 2025 Mar 13, 2025

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 )

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 13, 2025 Mar 13, 2025
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 13, 2025 Mar 13, 2025
LATEST

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 )

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines