Is it possible to configure JPG export settings in a UXP InDesign plugin? If so, could anyone share a code example?
Need something similar to this ExtendScript example:
app.jpegExportPreferences.properties = {
exportingSpread: false,
jpegQuality: JPEGOptionsQuality.HIGH,
jpegRenderingStyle: JPEGOptionsFormat.BASELINE_ENCODING,
exportResolution: 300,
jpegColorSpace: JpegColorSpaceEnum.RGB,
embedColorProfile: true,
antiAlias: true,
useDocumentBleeds: false,
simulateOverprint: false
};
I figured out a workaround using doScript. If there is a UXP way to do it please let me know.
function set_jpg_export_preferences () {
const jpg_export_settings =
"app.jpegExportPreferences.properties = {" +
"exportingSpread: false," +
"jpegQuality: JPEGOptionsQuality.HIGH," +
"jpegRenderingStyle: JPEGOptionsFormat.BASELINE_ENCODING," +
"exportResolution: 300," +
"jpegColorSpace: JpegColorSpaceEnum.RGB," +
"embedColorProfile: true," +
"antiAlias: true," +
"useDocumentBleeds: false," +
"simulateOverprint: false" +
"};";
app.doScript(jpg_export_settings, ScriptLanguage.JAVASCRIPT);
}
sttk3
3
Your code was available almost as is.
const {
app,
ExportFormat,
JPEGOptionsQuality,
JPEGOptionsFormat,
JpegColorSpaceEnum
} = require('indesign') ;
(() => {
if(app.documents.length <= 0) {return ;}
const doc = app.activeDocument ;
if(doc.selection.length <= 0) {return ;}
const sel = doc.selection[0] ;
const docName = doc.name.replace(/\.[a-z0-9]{2,4}$/i, '') ;
const targetPath = `/Users/username/Desktop/${docName}-item1.jpg` ;
app.jpegExportPreferences.properties = {
exportingSpread: false,
jpegQuality: JPEGOptionsQuality.HIGH,
jpegRenderingStyle: JPEGOptionsFormat.BASELINE_ENCODING,
exportResolution: 300,
jpegColorSpace: JpegColorSpaceEnum.RGB,
embedColorProfile: true,
antiAlias: true,
useDocumentBleeds: false,
simulateOverprint: false
} ;
sel.exportFile(ExportFormat.JPG, targetPath, false) ;
})() ;
1 Like
sttk3, thank you! worked perfectly. I really appreciate it.
1 Like