Copy link to clipboard
Copied
Hello,
When exporting svg files through scripting, Illustrator CC includes the viewBox attribute in the <svg> tag – but not width and height. This makes display inconsistent and problematic in web browsers.
Is there a way to include width and height attributes when exporting from Illustrator CC? CS6 did it automatically.
Copy link to clipboard
Copied
I have the same issue. Does anyone have a solution for this?
Copy link to clipboard
Copied
If you uncheck 'Responsive' in the export options, width and height should be included.
If this doesn't work for you, please share an example file along with the exact export options you used.
Copy link to clipboard
Copied
I'm using the `app.activeDocument.exportFile()` API. `ExportOptionsSVG` does not seem to have a "responsive" option that I can set to `false`?
Copy link to clipboard
Copied
Apologies, I missed the scripting tag. Please see this thread:
https://community.adobe.com/t5/illustrator-discussions/scripting-svg-export-quot-object-ids-quot-and...
Copy link to clipboard
Copied
Thank you for the link.
Still struggeling to use `app.activeDocument.exportFile()` together with `ExportType.WOSVG` and `ExportOptionsWebOptimizedSVG` though.
Getting a "opperation not supported on this object" error.
Example code:
```
var exportOptions = new ExportOptionsWebOptimizedSVG();
exportOptions.svgResponsive = false;
exportOptions.artboardRange = 1;
var fileSpec = new File('test.svg');
app.activeDocument.exportFile(fileSpec, ExportType.WOSVG, exportOptions);
```
Copy link to clipboard
Copied
After a long search I've found that my document i'm trying to `exportFile()` is a so called "large scale canvas". And there is a bug in `exportFile()` where it fails on a "large scale canvas" with the error code: "opperation not supported on this object".
Source: https://community.adobe.com/t5/illustrator-discussions/exporting-selected-objects-to-dxf/m-p/9790603...
Copy link to clipboard
Copied
Unfortunately there is no way to change the canvas size of a document. I'll have to create a new document and copy paste my artwork to that document in order to use `exportFile()` (with `ExportOptionsWebOptimizedSVG`).
The facts that all this is not properly documented makes it very frustrating scripting anything for adobe applications.