Skip to main content
Participant
August 23, 2016
Question

Illustrator PDF save script with filename append

  • August 23, 2016
  • 1 reply
  • 805 views

I've seen many threads on scripting but they all seem to assume some basic knowledge of the languages (which I unfortunately do not). Everything I try just seems to end with a blank dialogue box and an exclamation point.

What I'm looking for is simple – a script that will save the current document as a "Smallest File Size" PDF, in the same folder as the open document, with a "_LORES.pdf" filename (ideally it would overwrite any file with the same name, as well).

This way, I could quickly and easily save a small PDF of a current layout in the same folder for populating into a presentation.

Any takers?

This topic has been closed for replies.

1 reply

Silly-V
Legend
August 23, 2016

Hello, check this out! And you can learn some JS - I started out myself by using Simon Allardice's lynda.com javascript for beginners tutorial. Of course then there's all the Illustrator-specific crap, but for stuff like this, the forum is king!

#target illustrator

function test(){

  var doc = app.activeDocument;

  var parentPath = Folder(File(doc.fullName).parent);

  var opts = new PDFSaveOptions();

  opts.pDFPreset = "[Smallest File Size]";

  doc.saveAs(File(parentPath + "/" + doc.name.replace(/\.\w+$/, "_LORES.pdf")), opts);

};

test();

Participant
August 27, 2016

I've tried this and some other options – I just get a "!" dialog box in Illustrator and nothing happens. Any other advice?

Silly-V
Legend
August 27, 2016

Can you say how you run this script?