Copy link to clipboard
Copied
Is there a way to export current project as svg in Illustrator with CEP panel using js or jsx ?
Copy link to clipboard
Copied
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()
);
}
Copy link to clipboard
Copied
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.