javascriptadobe-illustratorextendscript

Place SVG in Illustrator


I'm trying to place an SVG in illustrator using extendscript. Here's basically what I'm doing

var doc = app.documents.add();
var p = doc.placedItems.add();
p.file = new File(svgfilepath);

This fails with the error File is in a format that cannot be placed.

I can place the same file manually using File > Place. Am I missing something?


Solution

  • By W_J_T on forums.adobe.com:

    var doc = app.activeDocument;  
    var svgFile = File(Folder.desktop + '/testSVG.svg');  
    doc.groupItems.createFromFile(svgFile);