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

Export InDesign document to Image File

Participant ,
Nov 01, 2023 Nov 01, 2023

Hi, 

I confidently exported a 10-page InDesign document to JPG, but I assertively need to exclude the master page from the export. Please guide me on this.

 

var doc = app.activeDocument;
for (var i = 0; i < doc.pages.length; i++) {
    var currentPage = doc.pages[i];
    app.jpegExportPreferences.exportResolution = 300; // Change resolution if needed
    var exportFile = new File("/C/Users/ADMIN/Documents//Page_" + (i + 1) + ".jpg"); 
    currentPage.exportFile(ExportFormat.JPG, exportFile);
}

 

 

-Monisha
TOPICS
How to , Scripting
882
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
Engaged ,
Nov 01, 2023 Nov 01, 2023

As i understand master page won't be executed using the code you shared.

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
Participant ,
Nov 01, 2023 Nov 01, 2023

The exported InDesign document shows an empty image file. Kindly find the attached screenshot.

 

MonishaRajendran_0-1698834847933.png

 

 

-Monisha
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
LEGEND ,
Nov 01, 2023 Nov 01, 2023

According to https://www.indesignjs.de/extendscriptAPI/indesign-latest/#about.html - you can't call ExportFile on a Page??

 

RobertTkaczyk_1-1698836172722.png

 

VB have Export - but it can't be called on a Page object ?

 

Is it from the latest version - 2024 / v19? Not upgraded yet.

 

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
Participant ,
Nov 01, 2023 Nov 01, 2023

Hi 

Sorry for the inconvenience, by using the below-given script I have achieved the export option but the blank pages appear in the export file path. I'm using the InDesign 2022 version 17.1

var doc = app.activeDocument;

for (var i = 0; i < doc.pages.length; i++) {
    var currentPage = doc.pages[i];
    app.jpegExportPreferences.exportResolution = 300; // Change resolution if needed
    var exportFile = new File("/C/Users/ADMIN/Documents/Page_" + (i + 1) + ".jpg"); // Change path and file format if needed

    currentPage.exportFile(ExportFormat.JPG, exportFile);
}

 

-Monisha
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
Participant ,
Nov 02, 2023 Nov 02, 2023

A page has no exportFile method, why your script fails to run.

Try the following approach:

var doc = app.activeDocument;

for(i=0; i<doc.pages.length; i++) {
	app.jpegExportPreferences.properties = {
		exportResolution: 300,
		jpegExportRange: ExportRangeOrAllPages.exportRange,
		pageString: String(i+1)
	};

	doc.exportFile(ExportFormat.JPG, File("/your/output/path/" + (i+1) + ".jpg"));
}

 Don't forget to update the output path as desired. The script should also exclude master pages from export.

____________________
Robotic Process Automation in Desktop Publishing (Book): https://doi.org/10.1007/978-3-658-39375-5
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
LEGEND ,
Nov 02, 2023 Nov 02, 2023
quote

A page has no exportFile method, why your script fails to run.

[...]


By @GNDGN

 

Yes, already mentioned, but for some strange reason - OP's script is working for him??

 

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 ,
Nov 02, 2023 Nov 02, 2023

I was about to post the same as @GNDGN —the page object doesn’t have an exportFile() method so when I run @MonishaRajendran ’s last script I get this expected error:

 

Screen Shot 20.png

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 ,
Nov 03, 2023 Nov 03, 2023

The doc.pages collection contains just document pages, not master pages, so it's not clear what Monisha has actually done.

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
LEGEND ,
Nov 03, 2023 Nov 03, 2023

Monisha and GNDGN are using some undocumented function for exporting 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 ,
Nov 03, 2023 Nov 03, 2023

GNDGN sets the page (range) to be exported, which is the standard method. Same goes for PDF.

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
LEGEND ,
Nov 03, 2023 Nov 03, 2023
LATEST

That's what I've suspected... 

 

https://community.adobe.com/t5/indesign-discussions/exportfile-export-selection-option-via-script/m-... 

 

@MonishaRajendran - what version of InDesign are you using?

 

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