Skip to main content
Inspiring
April 13, 2023
Answered

pdf export with jsx script

  • April 13, 2023
  • 5 replies
  • 1968 views

hi all

I want to create to pdf of my indd doc using job options preset.

One pdf is hires and the other low res.

this is my MAC OS script:

var doc = app.activeDocument;
var filePath = doc.filePath;

// Impostazioni job options
var pressQualityJobOptions = File("/Library/Application Support/Adobe/Adobe PDF/Settings/Press Quality.joboptions");

var lightJobOptions = File("/Library/Application Support/Adobe/Adobe PDF/Settings/versione light.joboptions");

// Esporta il PDF con le impostazioni "Press Quality"
var pdfPressQuality = app.pdfExportPresets.itemByName("Press Quality");
doc.exportFile(ExportFormat.pdfType, File(filePath + "/" + doc.name.replace(/\.[^\.]+$/, '') + ".pdf"), false, pdfPressQuality, pressQualityJobOptions);

// Esporta il PDF con le impostazioni "versione light"
var pdfLight = app.pdfExportPresets.itemByName("versione light");
doc.exportFile(ExportFormat.pdfType, File(filePath + "/" + doc.name.replace(/\.[^\.]+$/, '') + " light.pdf"), false, pdfLight, lightJobOptions);

 

when I run the script I receive this msg:

JavaScript Error!
Codice errore: 30477
Stringa errore: Valore non valido per il parametro "using" del metodo
"exportFile". Era previsto PDFExportPreset, ma è stato ricevuto nothing.
Motore: main
File: /Users/macstudio01/Library/Preferences/Adobe InDesign/
Version 18.0/it IT/Scripts/Scripts Panel / mio script PDF.is>
Riga: 11
Sorgente: doc.exportFile(ExportFormat.pdfType, File(filePath + "/" +
doc.name.replace(/\.[^\.]+ $/, ") + "pdf"), false, pdfPressQuality,
pressQualityJobOptions);

it seems script cant locate the job options

could you help me please?
thx

Correct answer Peter Kahrel

The predefined job options are in brackets, you should include them:

var pdfPressQuality = app.pdfExportPresets.itemByName("[Press Quality]");

You should check whether the job option exists:

if (!app.pdfExportPresets.itemByName("[Press Quality]").isValid) {
  alert (". . .");
  exit();
}

Also, the fifth parameter in your two export instances is for version comments, not another job option.

 

P.

5 replies

Peter Kahrel
Community Expert
Community Expert
April 13, 2023

You can show the presets via File > Adobe PDF Presets, see the screenshot. You should use preset names exactly as you see them there (apart from the three dots).

 

 

Community Expert
April 13, 2023

Hi @milko259349307s4y ,

also note that the name of the PDF export preset is localized.

So Peter's sample code would return an alert when run on my German InDesign.

Its name in my German version is "[Druckausgabequalität]" for "[Press Quality]".

 

Regards,
Uwe Laubender
( Adobe Community Expert )

Inspiring
April 13, 2023

yes, I understood it,

thankyou Laubender

Peter Kahrel
Community Expert
Peter KahrelCommunity ExpertCorrect answer
Community Expert
April 13, 2023

The predefined job options are in brackets, you should include them:

var pdfPressQuality = app.pdfExportPresets.itemByName("[Press Quality]");

You should check whether the job option exists:

if (!app.pdfExportPresets.itemByName("[Press Quality]").isValid) {
  alert (". . .");
  exit();
}

Also, the fifth parameter in your two export instances is for version comments, not another job option.

 

P.

Inspiring
April 13, 2023

thank you Peter for reply.

I've added the check for job options and the script tell me there is no job option [alert (". . .")]

After debugging the filename, the script WORKS!

 

Grazie, ti devo una birra
🙂