Skip to content

Instantly share code, notes, and snippets.

@martgnz
Created January 17, 2018 15:08
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save martgnz/d40ab35b5d69caea00918d8aed807ef1 to your computer and use it in GitHub Desktop.
Save martgnz/d40ab35b5d69caea00918d8aed807ef1 to your computer and use it in GitHub Desktop.
Batch convert PDF to AI
(function(thisObj) {
main();
function main() {
var pdffiles = File.openDialog(
'Select one or more PDF files',
'*.pdf',
true,
);
if (pdffiles === null) {
return;
}
for (var f = 0; f < pdffiles.length; f++) {
var pdf = pdffiles[f];
//~ alert(pdf);
var doc = app.open(pdf);
var namepattern = pdf.path + '/' + pdf.name + '.converted.ai';
var newai = null;
if (!File(namepattern).exists) {
newai = new File(namepattern);
} else {
newai = File(namepattern);
}
doc.saveAs(newai);
doc.close(SaveOptions.DONOTSAVECHANGES);
}
}
})(this);
@cesar-acosta551
Copy link

Awesome! time saving! thanks you so much

@bakerwm
Copy link

bakerwm commented Aug 6, 2023

It works great.

  1. save the above code as "pdf2ai.jsx";
  2. open Adobe Illustrator;
  3. go to "File" -> "Script" -> "Other Script..." -> Choose the file pdf2ai.jsx -> Choose the PDF files
  4. (support multiple pdf files at once)

@unihumi
Copy link

unihumi commented Sep 14, 2023

Awesome. Thanks alot. Is it somehow possible to shrink down the "artboard" of each AI file to its corresponding layers within? All the AI files that have been created by Illustrator now have a greater Artboard than neccessary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment