Skip to main content
Participant
September 13, 2023
Question

Export ai to SVG creating PNG and JPG file

  • September 13, 2023
  • 1 reply
  • 1847 views

I have a tool that automates AI. It opens a .ai file and then calls Export passing in AiExportType.aiSVG. I pass in an ExportOptionsSVG object too. When I call Export, I see that I not only get the SVG file created, but I also see either a JPG or PNG file created too. Those filenames are "random" in that the filenames appear to just be hex numbers. For instance, I just got 1338D1F3.jpg for a file. I suspect that the type, jpg or png created may depend on whether there are text frames or not in the .ai file. But, that's just a guess right now. I don't see any option in the APIs for Illustrator.Application, Illustrator.Document or the export options object that would let me stop this from occurring.

 

How can I prevent this from occurring programmatically (via the automation APIs)?

This topic has been closed for replies.

1 reply

CarlosCanto
Community Expert
Community Expert
September 13, 2023

If you create a new document and draw a plain rectangle with default fill and stroke, then export to svg using your tool, does it create the jpg/png files?

 

if it didn't then, it's probably not the code but the art that is causing the issue

Known Participant
September 14, 2023

Regardless of what "causes" this, I want to avoid it. I don't see any API on Artboard or Artboards that would appear to help me avoid these files being created. I do know we have created png files from the .ai files directly via the UI, so that might be why it is insisting on dropping those to disk when I call Export to create the SVG. Indeed, if I don't supress adding the .ai files I open to the MRU and I later open a .ai file later via the UI, Illustrator puts up a message box complaining that it can't find a png file for the .ai file. When our team creates a png from the .ai file, they use the same name and just change the extension. These files created by Export don't use those names, which is probably why Illustrator is saying it can't find the png file.

 

I just want to stop these randomized files being created.

CarlosCanto
Community Expert
Community Expert
September 15, 2023

got them, these links work, let me have a look.


ok, 

 

1. your file has a linked image that might be there intentionally or not.

2. This linked image won't cause any issues when you export to svg, it will remain linked whether EmbedRasterImages is set to true or false

 

3. I don't have the linked image so I replaced that with one I have. 

4. now if I embed the image and export to svg with EmbedRasterImages set to "false", then the image will be "unembedded", in other words, it will be saved to disk along with the svg.

 

so, set EmbedRasterImages = true, or if the link is not supposed to be there, then sort that out before exporting to svg