Place SVG via script
I have a script I have used to place Illustrator art inside of other open documents. It places them at the coordinates in the code. I have come up with the need to place dynamically created SVG files into Illustrator documents. When I try to use the script for placing SVG, it does not work (gives a bunch of errors). I can manually place the SVG file into Illustrator. However, I cannot have the position predetermined as the script can do. When I place the SVG, it is only the art, not any artboard or bounding area like the Illustrator (.ai) file. This works well for my application now. If there is any way to do it, I would like to find out. Thanks
var doc = app.activeDocument;
// Replace this with your actual file path
var filePath = new File("C:/Test/data1990.svg");
if (filePath.exists) {
var placedItem = doc.placedItems.add();
placedItem.file = filePath; // Assign file to placed item
placedItem.position = [100, 200]; // X = 100, Y = 200 (Adjust as needed)
} else {
alert("Error: File not found! Check the file path.");
}
