Skip to main content
New Participant
January 18, 2020
Question

Export current project as SVG with CEP

  • January 18, 2020
  • 1 reply
  • 856 views

Is there a way to export current project as svg in Illustrator with CEP panel using js or jsx ?

This topic has been closed for replies.

1 reply

Inventsable
Legend
January 19, 2020

Hi, what do you mean by "Project"? The active document with one artboard, or all artboards, etc?

You can run an evalScript call in JS on a JSX function like this:

function exportFileToSVG(path) {

  // Replace current file extension with .svg
  var name = app.activeDocument.name.replace(/\.[\w]*/, ".svg");

  // Then export file (active artboard) of the activeDocument
  app.activeDocument.exportFile(
    new File(path + name),
    ExportType.WOSVG,
    new ExportOptionsWebOptimizedSVG()
  );
}



New Participant
January 19, 2020

I mean current file or active layer (selected layer) If I have a list with many layers I want to save all selected layers like individual file with svg extension but I don't know if in Illustrator exists some events like in photoshop to listen at mouse event to check if exists some selected layers and also export it like svg.

Or another case wich is the best practice for me is to extract the svg content from selected layer with jsx and transport it back to js file without saving all files like svg on disk.

You snippet works very well, thank you.