Skip to main content
heathkat
Participant
May 2, 2016
Answered

Help finding source of "undefined" error?

  • May 2, 2016
  • 1 reply
  • 552 views

Hello All,

I wrote a script to export a jpeg from page 1 of an InDesign document. When I run it, I get an error that "jpegOptionsQuality is undefined".  I believe it's referring to the emphasized line in my script below, but I don't see anything wrong with the line or any neighboring lines. Does anyone see my problem?

I've done a lot of scripting in VB but am fairly new to Javascript.

Any help is appreciated. 🙂

MakeJPEGfile();

function MakeJPEGfile() {

  var myDoc = app.activeDocument;

    app.jpegExportPreferences.jpegQuality = jpegOptionsQuality.MAXIMUM;

    app.jpegExportPreferences.exportResolution = 72;

    app.jpegExportPreferences.jpegExportRange = ExportRangeOrAllPages.EXPORT_RANGE;

    app.jpegExportPreferences.pageString = "1";

    app.jpegExportPreferences.jpegQuality = jpegOptionsQuality.HIGH;

    app.jpegExportPreferences.exportResolution = 154;

    app.jpegExportPreferences.jpegColorSpace = jpegColorSpaceEnum.RGB;

    app.jpegExportPreferences.jpegRenderingStyle = jpegOptionsFormat.BASELINE_ENCODING;

    app.jpegExportPreferences.antiAlias = true;

    app.jpegExportPreferences.embedColorProfile = true;

var myFilePath = myDoc.filePath + "/" + ".jpg"; //export to a folder of the current document

var myFile = new File(myFilePath);

myDoc.exportFile(ExportFormat.jpg, myFile, false);

}

This topic has been closed for replies.
Correct answer TᴀW

I take that back. The DOM isn't consistent here. So

JPEGOptionsQuality.HIGH

and

JPEGOptionsFormat.BASELINE_ENCODING

are both correct,

but it should be:

JpegColorSpaceEnum.RGB

Ariel

1 reply

TᴀW
Legend
May 2, 2016

Looks like a capitalization issue. Try:

JPEGOptionsQuality.HIGH

Also:

JPEGColorSpaceEnum.RGB

and

JPEGOptionsFormat.BASELINE_ENCODING

Ariel

Visit www.id-extras.com for powerful InDesign scripts that save hours of work — automation, batch tools, and workflow boosters for serious designers.
TᴀW
TᴀWCorrect answer
Legend
May 2, 2016

I take that back. The DOM isn't consistent here. So

JPEGOptionsQuality.HIGH

and

JPEGOptionsFormat.BASELINE_ENCODING

are both correct,

but it should be:

JpegColorSpaceEnum.RGB

Ariel

Visit www.id-extras.com for powerful InDesign scripts that save hours of work — automation, batch tools, and workflow boosters for serious designers.
TᴀW
Legend
May 2, 2016

Oh, and change that first one to:

JPEGOptionsQuality

as well...

Visit www.id-extras.com for powerful InDesign scripts that save hours of work — automation, batch tools, and workflow boosters for serious designers.