Skip to main content
Known Participant
June 12, 2017
Answered

Script to Set Default PDF Presets

  • June 12, 2017
  • 2 replies
  • 5271 views

Hi guys -

I've been looking around for awhile for something that would help increase our workflow's efficiency. We have a certain setting we save all of our PDFs in [Color Press], but I can't figure out to set that as the default preset. Every time we Save As PDF, we have to change the PDF setting to [Color Press] manually. 

Is there a way to do so in AI or a script that will Save an open file to a preset instead of the [Illustrator Default]? We would ideally still need the option to choose where to save the PDF, as not all of our PDFs get saved into the same folder as the AI file.

Thanks in advance!

This topic has been closed for replies.
Correct answer Loic_Aigon1

This should help :

var main = function() {

var doc;

if ( !app.documents.length ) {

return;

}

doc = app.activeDocument;

var psts = app.PDFPresetsList;

var n = psts.length;

var found = false;

var presetName = "LUDILABEL",

f;

while ( n-- ) {

if ( psts==presetName) {

found = true;

break

}

}

if ( !found ) {

alert("Unable to find pdf preset "+presetName );

return;

}

var opts = new PDFSaveOptions();

opts.pDFPreset = presetName;

f= File.saveDialog ("Where di you want to save the file ?");

if ( !f ) return;

doc.saveAs ( f, opts );

}

main()

Loic

Ozalto | Productivity Oriented - Loïc Aigon

2 replies

Inspiring
June 13, 2017

In fact it's even needless. If you need to save it to the exact location of the active document and given it's saved already, you could save directly with

doc.saveAs ( File ( app.activeDocument.fullName.replace ( /\.ait?$/i, "")+".pdf" ) );

hence avoiding the need of a dialog.

Known Participant
June 14, 2017

That makes sense, we do occasionally need to save it in another folder as well so it's nice to have both options.

From what I've read, hotkeying a script to an action (Insert Menu Item) will reset every time Illustrator is restarted. There's no known workaround for this yet correct?

Thank you again!

Loic_Aigon1Correct answer
Inspiring
June 13, 2017

This should help :

var main = function() {

var doc;

if ( !app.documents.length ) {

return;

}

doc = app.activeDocument;

var psts = app.PDFPresetsList;

var n = psts.length;

var found = false;

var presetName = "LUDILABEL",

f;

while ( n-- ) {

if ( psts==presetName) {

found = true;

break

}

}

if ( !found ) {

alert("Unable to find pdf preset "+presetName );

return;

}

var opts = new PDFSaveOptions();

opts.pDFPreset = presetName;

f= File.saveDialog ("Where di you want to save the file ?");

if ( !f ) return;

doc.saveAs ( f, opts );

}

main()

Loic

Ozalto | Productivity Oriented - Loïc Aigon

Known Participant
June 13, 2017

Thank you so much Loic! This seems to be what we were looking for. 2 quick questions for you -

1) Is there a way to keep the filename when saving without having to retype it? When I run this script I have to rename the file (it's blank)

2) Can the default location to save open up where the AI file is located? Right now it opens up to save in the most recently saved location.

Thank you again, and sorry for the flurry of questions!

Inspiring
June 13, 2017

var main = function() { 

var doc; 

if ( !app.documents.length ) { 

return; 

doc = app.activeDocument; 

var psts = app.PDFPresetsList; 

var n = psts.length; 

var found = false; 

var presetName = "SOME_PRESET_NAME",  

f; 

while ( n-- ) { 

if ( psts==presetName) { 

found = true; 

break ;

if ( !found ) { 

alert("Unable to find pdf preset "+presetName ); 

return; 

 

var opts = new PDFSaveOptions(); 

opts.pDFPreset = presetName; 

f = File ( doc.name );

f= f.saveDlg ("Where do you want to save the file ?"); 

if ( !f ) return; 

doc.saveAs ( f, opts ); 

 

main();

Here it is…