Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
1

"width" and "height" attributes not included on svg export

Explorer ,
Jun 23, 2014 Jun 23, 2014

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.

TOPICS
Scripting
554
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
Community Beginner ,
May 08, 2024 May 08, 2024

I have the same issue. Does anyone have a solution for this?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 08, 2024 May 08, 2024

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
May 08, 2024 May 08, 2024

I'm using the `app.activeDocument.exportFile()` API. `ExportOptionsSVG` does not seem to have a "responsive" option that I can set to `false`?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 08, 2024 May 08, 2024
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
May 08, 2024 May 08, 2024

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);
``` 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
May 13, 2024 May 13, 2024

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...

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
May 13, 2024 May 13, 2024
LATEST

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines