Skip to main content
Known Participant
February 1, 2017
Answered

SVG Export only visible layers

  • February 1, 2017
  • 1 reply
  • 6443 views

I'm back! I was never leaving haha.

So I am trying to export an svg file for only the visible layer. I am able to do this manually by

Export as SVG, use artboards, and these options

When I do it this way, it only saves the visible layer. However, when I use the code below, it saves all the layers even hidden ones, and all the raster images involved.

var docRef = app.activeDocument;

var path = docRef.path;

function exportFileToSVG (dest) {

   

    if ( app.documents.length > 0 ) {

        var exportOptions = new ExportOptionsSVG();

        var type = ExportType.SVG;

        var fileSpec = new File(dest);

       

        exportOptions.saveMultipleArtboards = true;

        exportOptions.coordinatePrecision = 2;

        exportOptions.fontType = SVGFontType.OUTLINEFONT;

       

        exportOptions.embedRasterImages = false;

        exportOptions.includeFileInfo = false;

        exportOptions.preserveEditability = false;

        app.activeDocument.exportFile( fileSpec, type, exportOptions );

    }

}

exportFileToSVG('~/Desktop/blah');

If anyone has any idea why all the layers are saving and not just the visible ones, please let me know. I can always create an action by how I saved it and then run the action through the full script, but I was hoping to script everything. Thanks!!

This topic has been closed for replies.
Correct answer Silly-V

Try using the: ExportOptionsWebOptimizedSVG object.

1 reply

Silly-V
Silly-VCorrect answer
Legend
February 1, 2017

Try using the: ExportOptionsWebOptimizedSVG object.

Known Participant
February 1, 2017

Thanks, I am not seeing that anywhere in the reference though. Do they have that in CC 2017?

Silly-V
Legend
February 1, 2017

Yea, I see it in the OMV -