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

Export InDesign document to Image File

Participant ,
Nov 01, 2023 Nov 01, 2023

Copy link to clipboard

Copied

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

Views

452

Translate

Translate

Report

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

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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

 

MonishaRajendran_0-1698834847933.png

 

 

-Monisha

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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.

 

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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??

 

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

Monisha and GNDGN are using some undocumented function for exporting pages? 

 

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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?

 

Votes

Translate

Translate

Report

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