Skip to main content
Participant
September 13, 2023
Question

Export ai to SVG creating PNG and JPG file

  • September 13, 2023
  • 1 reply
  • 1828 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.

Known Participant
September 14, 2023

I think this is due to the active Artboard. I see there is a Formats section in the Exports For Screens dialog and the "Format" dropdown is set to PNG. I just don't see a way to turn that off programmatically. Also, since I am processing .ai files created by another team, I see that the "Export to:" setting points to a Windows "Users\xxx\Downloads\" folder (xxx is the user name). So, since I don't have the specific user folder, perhaps that is why Illustrator is dropping these unwanted files in the folder where I Export the SVG. Guess I'll have to add code to enum all png and jpg files in that folder before I export and then enum again and remove any new files.