Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Programmatic SVG Export

Explorer ,
May 19, 2016 May 19, 2016

I'm creating an HTML Panel Extension and want to query the Illustrator Canvas path data.  The end goal is to automatically create an SVG of the illustrator file and port this onto the web.  The Javascript API doesn't have an option to save an SVG file, so I'd like to find a way to access the algorithm used for saving an SVG file.

The user should not have to save out an svg file. It would be preferable to send the SVG data from .JSX to HTML/JS. If anyone can point me in the right direction or offer sample files, it'd be very much appreciated!

TOPICS
SDK
1.8K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Enthusiast , May 21, 2016 May 21, 2016

Hi,

you could export art to svg using extendscript.

Here is a sample (.jsx):

saveAsSVG: function (filePath) {

    try {

      var svgFile = new File(filePath);

      var exportOptions = new ExportOptionsSVG();

      exportOptions.embedRasterImages = ....;

      exportOptions.embedAllFonts = ...;

      exportOptions.fontSubsetting = SVGFontSubsetting.GLYPHSUSED;

      exportOptions.fontType = SVGFontType.SVGFONT;

      app.activeDocument.exportFile(svgFile, ExportType.SVG, exportOptions);

    } catch (ex) {

 

...
Translate
Adobe
Enthusiast ,
May 21, 2016 May 21, 2016

Hi,

you could export art to svg using extendscript.

Here is a sample (.jsx):

saveAsSVG: function (filePath) {

    try {

      var svgFile = new File(filePath);

      var exportOptions = new ExportOptionsSVG();

      exportOptions.embedRasterImages = ....;

      exportOptions.embedAllFonts = ...;

      exportOptions.fontSubsetting = SVGFontSubsetting.GLYPHSUSED;

      exportOptions.fontType = SVGFontType.SVGFONT;

      app.activeDocument.exportFile(svgFile, ExportType.SVG, exportOptions);

    } catch (ex) {

     //do whatever you want!

    }

  }

you could even save selection or asset as svg.

Thomas.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Feb 16, 2017 Feb 16, 2017
LATEST

Hi,

You mentioned that it can be used to save a selection, but how?

This example is exporting the whole document and I can't find any option for the selection... 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines