Copy link to clipboard
Copied
Okay, I found out how to modify the "Save as PDF" javascript supplied with Illustrator so that it renders the .pdf with my preferred .joboption (e.g. X3) - what I'm lacking and don't seem to be able to find out via google is how to suppres the save dialogue (asking me about the location where to save the file every time I invoke that script).
I'd like the script to save the PDF
- in exactly the same location as the .ai document
- overwrite any probably existing .pdf file with the same name without asking
Can anybody here help me how to do this trick?
Thx in advance!
...var doc = app.activeDocument;
var pdfOption = 'PDFX3_CanDo_X3'; // Name of your PDF setting
var pdfSuff = '.pdf'; // Suffix for PDF
function getOptions (set) {
var options = new PDFSaveOptions ();
options.pDFPreset = set;
return options;
}
function saveCopyAsPDF (set, suff) {
var original_file = doc.fullName;
var arr = doc.name.split(".");
var extension = "";
if (arr.length > 1) {
extension = "." + arr.pop()
};
var filename = arr.j
Copy link to clipboard
Copied
var doc = app.activeDocument;
var pdfOption = 'PDFX3_CanDo_X3'; // Name of your PDF setting
var pdfSuff = '.pdf'; // Suffix for PDF
function getOptions (set) {
var options = new PDFSaveOptions ();
options.pDFPreset = set;
return options;
}
function saveCopyAsPDF (set, suff) {
var original_file = doc.fullName;
var arr = doc.name.split(".");
var extension = "";
if (arr.length > 1) {
extension = "." + arr.pop()
};
var filename = arr.join(".");
var destFolder = null;
destFolder = activeDocument.path
var options = this.getOptions (set);
var targetFile;
targetFile = this.getTargetFile (filename, suff, destFolder);
doc.saveAs (targetFile, options);
doc.close ();
app.open (File (original_file));
}
function getTargetFile (docName, ext, destFolder) {
var newName = "";
newName = docName + ext;
var myFile = new File (destFolder + '/' + newName);
return myFile;
}
saveCopyAsPDF (pdfOption, pdfSuff);
You will have to modify at least the second line and insert the name of your own pdf export settings. The script saves a PDF of your active document in the same folder as the original AI. After that it closes the PDF and re-opens the original AI file.
Copy link to clipboard
Copied
This is brilliant. I have been searching for years for a script that would use a PDF preset to save out a PDF. Thank you!
Copy link to clipboard
Copied
This is the closest workaround to EXPORTING the current file to PDF, however since it SAVES to PDF and then re-opens your original AI file, you lose any ability to UNDO previous actions.
If you wish Adobe would give us a proper Export PDF menu, (as it already exists in inDesign), please vote up this feature request here:
Copy link to clipboard
Copied
Is it possible to set this up to batch a folder of AI files? I was trying to do something similar with the Save As PDF Sample script but could not get it to work with my PDF preset.
Copy link to clipboard
Copied
Works like a charm - thank you very much!! ![]()
Copy link to clipboard
Copied
Only for addition
To change the original Save as PDF.jsx:
Change line #52 to
destFolder = sourceFolder;
To suppres the prompt (which ask for the file type) - comment out line #44 and
change line #47 to
files = sourceFolder.getFiles ("*.ai");
Have fun
![]()
Find more inspiration, events, and resources on the new Adobe Community
Explore Now