Highlighted

Pdf preset

Community Beginner ,
Jul 25, 2020

Copy link to clipboard

Copied

Hi everyone,

I need a script to import the two preset and it doesn't duplicate the presets again run the script.  The script need to validate and remove the duplicating preset

TOPICS
Scripting

Views

94

Likes

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

Pdf preset

Community Beginner ,
Jul 25, 2020

Copy link to clipboard

Copied

Hi everyone,

I need a script to import the two preset and it doesn't duplicate the presets again run the script.  The script need to validate and remove the duplicating preset

TOPICS
Scripting

Views

95

Likes

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
Jul 25, 2020 0
Adobe Community Professional ,
Jul 25, 2020

Copy link to clipboard

Copied

Try the following code, it will check if the preset is already loaded if yes it will delete and then load the new preset. Change the filename according to your path

var pp = app.pdfExportPresets.itemByName("Exporter")
if(pp.isValid == true)
	pp.remove()
	
app.importFile(ExportPresetFormat.PDF_EXPORT_PRESETS_FORMAT, File("/Users/manan/Desktop/Exporter.joboptions"))

-Manan

Likes

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
Reply
Loading...
Jul 25, 2020 0
Community Beginner ,
Jul 25, 2020

Copy link to clipboard

Copied

Thanks Manan,

 

Likes

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
Reply
Loading...
Jul 25, 2020 0
Community Beginner ,
Jul 25, 2020

Copy link to clipboard

Copied

Hi Manan,

This is mycode:

But it wont works

var myFile = new File (pdfSetting1)
app.importFile(ExportPresetFormat.pdfExportPresetsFormat, myFile)
var myFile1 = new File (pdfSetting2)
app.importFile(ExportPresetFormat.pdfExportPresetsFormat, myFile1)

 
if (answer === "test"){
var preset1 = app.pdfExportPresets.itemByName("test")
var pdfFile = new File(path)
doc.exportFile(ExportFormat.PDF_TYPE,pdfFile,false,preset1)
if(preset1.isValid == true)
  preset1.remove()
} else if (answer === "test1") {
var preset2 = app.pdfExportPresets.itemByName("test1");
var pdfFile1 = new File(path)
doc.exportFile(ExportFormat.PDF_TYPE,pdfFile1,false,preset2)
if(preset1.isValid == true)
  preset1.remove()
}

Likes

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
Reply
Loading...
Jul 25, 2020 0
Adobe Community Professional ,
Jul 25, 2020

Copy link to clipboard

Copied

Hi Vijay,

 

Your code is definitely not complete and its not correct even. I will mention points as to what is wrong in it

  • pdfSetting1 and pdfSetting2 are undefined, you never assigned any path to them
  • You import the presets denoted by the above two presets, without checking if it is present or not. This is not what you asked. You should do as i did, in the code snippet i gave, first check if it's present, delete and then load
  • Again answer variable is not defined and you use it in if to test the condition

The code after this incomprensible its convoluted to be precise. What i gave you should suffice for your needs, just change the preset name and the filepath for the joboptions in it and it will work as you asked. To repeat it for multiple files, change it into a function, if that is complex for you then just copy these lines again and do the preset name and path change again and you should be done

 

-Manan

Likes

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
Reply
Loading...
Jul 25, 2020 2
Community Beginner ,
Jul 25, 2020

Copy link to clipboard

Copied

Sorry Manan 

That is my mistake I was not clearly mentioned the actual things want.

The real scenario is the two variables pdfSetting1 and pdfSetting2 are two preset to import from my local path and after import into the application to export the pdf again i run the script could not duplicate. 

Likes

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
Reply
Loading...
Jul 25, 2020 0
Adobe Community Professional ,
Jul 26, 2020

Copy link to clipboard

Copied

So you want to load a preset? In that case you use:

 

app.importFile(ExportPresetFormat.PDF_EXPORT_PRESETS_FORMAT, theFile);

 

Then you can reference it by whatever the export name of the file is:

app.pdfExportPresets.itemByName("the name");

 

Review the Application DOM object. 

Likes

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
Reply
Loading...
Jul 26, 2020 0
Adobe Employee ,
Sep 01, 2020

Copy link to clipboard

Copied

Hi there,

 

I'm hoping that the issue is resolved for you. If any of the above-mentioned solutions or suggestions helped, please mark them correct. If not, do let us know so that we can assist you further.

 

Regards,

Ashutosh

Likes

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
Reply
Loading...
Sep 01, 2020 0