Skip to main content
New Participant
May 2, 2023
Question

Replace external PDF JobOptions

  • May 2, 2023
  • 1 reply
  • 298 views

Hello, 

I work on Windows, and for my client I test on Mac and windows. 

 

I use importFile into a plugin for Indesign to get any pdfExportPresetFormat that a service send me.

 

It's ok, but when I recall that function to get an updated version of my pdfExportPresetFormat, I have a new one instead : 

- myPreset

- myPreset_1

- myPreset_2

...

 

I want to replace the first .jobOptions with a new one with the same name, so

function importPresetFile(filepath, name) {
    if (app.pdfExportPresets.item(name) != null) {
        app.pdfExportPresets.item(name).remove();
    }
    app.importFile(ExportPresetFormat.pdfExportPresetsFormat, filepath);
}

 

Sometimes it works, but sometimes the right to delete is not acquired, and I can just import the same document at the end of the list.

I checked this forum and the doc, maybe I am missing something, please help me.

Tanks in advance.

This topic has been closed for replies.

1 reply

Loic.Aigon
Brainiac
May 2, 2023

Maybe try:

 

function importPresetFile(filepath, name) {
    
    var pst = app.pdfExportPresets.itemByName(name);
    pst.isValid && pst.remove();

    app.importFile(ExportPresetFormat.pdfExportPresetsFormat, filepath);
}