Copy link to clipboard
Copied
I need script to save illustrator file to lores in same directory of AI file with same file naming.
Please help me on this.
Thanks
Hi,
Try this
function saveAsPDF() {
var pdfFile = new File(app.activeDocument.path + "/" + app.activeDocument.name.split('.')[0] + '.pdf');
var pdfOptions = new PDFSaveOptions();
pdfOptions.compatibility = PDFCompatibility.ACROBAT5;
pdfOptions.generateThumbnails = true;
pdfOptions.preserveEditability = false;
pdfOptions.preset = "[Smallest File Size]";
app.activeDocument.saveAs(pdfFile, pdfOptions);
}
saveAsPDF()
This will allow you save Illustartor document in PDF fo
...Copy link to clipboard
Copied
function saveAsPDf()
{
var doc = app.activeDocument;
var saveName = doc.fullName.replace(/\.ai$/,".pdf");
var pdfSaveOpts = new PDFSaveOptions();
//change this to whatever preset you want;
pdfSaveOpts.preset = "[Smallest File Size]";
doc.saveAs(File(saveName,pdfSaveOpts));
}
saveAsPDf();
Copy link to clipboard
Copied
Hi there,
You should be able to use this:
// The active document
var doc = app.activeDocument;
// The path of the original document
var originalDocPath = doc.path;
// The name of the original document
var originalDocName = doc.name;
// An array of all the layers in the active document
var allLayers = doc.layers;
// Get just the file name. Ignore the file extension .pdf and .ai
originalDocName = originalDocName.replace(/\.pdf|\.ai/gi, "")
{
// Setup pdf save options
var opts = new PDFSaveOptions();
// Use the preset named "XXX"
opts.pDFPreset = "your PDF preset name here";
// Save the document in the original folder using the original name with _LR suffix
doc.saveAs(File(originalDocPath + "/" + originalDocName + "_LR.pdf"), opts);
app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
}
Obviously you'll need a Low Res PDF preset as just naming the file with _LR.pdf won't achieve that. And you can comment out the 'app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);' if you don't want your file to close after saving the PDF. That's just the way we do things with this script.
Copy link to clipboard
Copied
Hello,
Is it possible to have the same script but with all the documents open and not just the active document?
Copy link to clipboard
Copied
Yes, it is possible. You have to loop over all the documents. Here is the sample script that will loop all the documents and save as PDF
function saveAsPDF() {
var allDocumentsLength = app.documents.length;
for (var i = allDocumentsLength - 1; i >= 0; i--) {
app.activeDocument = app.documents[i]; // Not necessary, only required whn you want to make document as active.
var doc = app.documents[i];
var pdfFile = new File(doc.path + "/" + doc.name.split('.')[0] + '.pdf');
var pdfOptions = new PDFSaveOptions();
pdfOptions.compatibility = PDFCompatibility.ACROBAT5;
pdfOptions.generateThumbnails = true;
pdfOptions.preserveEditability = false;
pdfOptions.preset = "[Smallest File Size]";
doc.saveAs(pdfFile, pdfOptions);
doc.close(SaveOptions.DONOTSAVECHANGES);
}
}
saveAsPDF();
Thanks
Copy link to clipboard
Copied
Thank you, by cons I do not see or I indicate the export setting that I want.
Copy link to clipboard
Copied
Hi,
What export setting you would like to use, please specify.
Copy link to clipboard
Copied
Bonjour,
On m'a aidé a trouver une réponse sur un autre post.
Il y a une erreur dans le code il faut remplacer :
pdfOptions.preset = "[Smallest File Size]";
par
pdfOptions.pDFPreset = "[Smallest File Size]";
Et après on peux choisir le parametre d'export PDF qu'on souhaite.
Copy link to clipboard
Copied
Im having alot of issues with saving as PDF.
I can save it as a regular AI file, but anytime i add PDFSaveOptions(), I get the error:
Enumerated value expected
or
Copy link to clipboard
Copied
Seems like a simple close/reopen fixed this problem
Copy link to clipboard
Copied
Hi! This script has helped me a lot, it is fantastic!
Do you know if there is any line of code to replace an existing file with the same name (including the _LR) when using the script?
Thank you so much
Copy link to clipboard
Copied
Would it be possible to save a HiRes and a LoRes version?
What changes would i have to make?
Thanks in advance!
Andreas
Copy link to clipboard
Copied
Yep. That would be very helpful. I have one for InDesign that exports PDFx1a>Medium>Low res pdfs all in one shot.
Copy link to clipboard
Copied
The script works perfect!
Is it possible to alter the script to save a lowres and a hires version ?
Copy link to clipboard
Copied
Hi,
Try this
function saveAsPDF() {
var pdfFile = new File(app.activeDocument.path + "/" + app.activeDocument.name.split('.')[0] + '.pdf');
var pdfOptions = new PDFSaveOptions();
pdfOptions.compatibility = PDFCompatibility.ACROBAT5;
pdfOptions.generateThumbnails = true;
pdfOptions.preserveEditability = false;
pdfOptions.preset = "[Smallest File Size]";
app.activeDocument.saveAs(pdfFile, pdfOptions);
}
saveAsPDF()
This will allow you save Illustartor document in PDF format.
Let us know if this helps you.
Thanks
Copy link to clipboard
Copied
please add close funtion at the end. dont need to save ai file it is already saved. once pdf is created file should be closed
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Hello,
there is way to select folder location before saving?
The rest script works fine!
Copy link to clipboard
Copied
Hi,
Yes, you can ask the user to select the location from the following line of code
var _location = Folder.selectDialog("Select location");
alert(_location);
Copy link to clipboard
Copied
It works great, thank you!
May be you can help me how i can set a default save location?
Copy link to clipboard
Copied
I forgot to mention that I am on win 10 and my save location is a network folder
\\STICKITSERVER2\stickitsyn\orders\