Copy link to clipboard
Copied
Hey,
I'm figuring out how to work with scripting and I did some reading in the scripting section, but that's all kinda chinese for me.
I'll explain what I just need:
1. I open a file ( named: FileA-ontwerp ) from folder A
2. I customize it
3. THIS IS WHERE I NEED MY SCRIPT FOR ( MAYBE WITH A KEYBOARD SHORTCUT ( F2 ) ? )
-> I want to save it in the ' smallest file size ' presets + adding a password and the name of the file should be 'FileA-ontwerp_LR.pdf' ( see attachment )
and it should be saved in the same folder A.
I tried this with an action and it works, BUT it takes the name from the file I recorded the action with and it saves the file in the folder of that preview file.
So not really the best system for me.
Is there anyone whoe can help me with this ? I don't have any scripting of js knowledge. If it's only possible with scripting, can someone tell me how i should implement a script please ?
Thanks in advance !
Tatiana
Copy link to clipboard
Copied
You should be able to use the following script. If you have the latest version of Illustrator, you can record playing this script into an action via Insert menu item command inside the flyout menu of the Actions panel. Such an action can have a hotkey assigned to it within Illustrator.
First you have to save the following text as a .jsx extension inside the Illustrator's application folder inside of the Presets/Scripts folder so that it appears in your File > Scripts menu as a menu item.
//@target illustrator
function test(){
if(app.documents.length == 0){
alert("No documents are open.");
return;
}
var doc = app.activeDocument;
if(doc.fullName.toString().length - doc.fullName.toString().replace(/\//g, "").length <= 1){
alert("Ensure open document is saved first.");
return;
}
alert("Proceed");
var opts = new PDFSaveOptions();
opts.pdfPreset = "[Smallest File Size]";
opts.permissionPassword = "abc123";
opts.requirePermissionPassword = true;
opts.enableCopy = false;
opts.enableCopyAccess = false;
opts.pdfChangesAllowed = PDFChangesAllowedEnum.CHANGE128NONE;
var newFile = File(doc.fullName.toString().replace(".ai", "_LR.pdf"));
doc.saveAs(newFile, opts);
};
test();
Copy link to clipboard
Copied
Thank you very much ! Works perfect.
Copy link to clipboard
Copied
Hey,
I discovered that it doesn't save as a small file size. If my .ai file is 4000kb, my _LR.pdf is 4000kb too.
Normaly it hould be 4000kb and 240kb or something.
The rest of it works perfect!
Copy link to clipboard
Copied
Hmm, I'll see if I can come back to it soon.
Copy link to clipboard
Copied
Hey,
did you gt any chance to check the code ? It would be a huuuuuuuuge lifehack for me
I do this process 20 or more times a day ..
Thanks in advance for yor help!