Skip to main content
MSAII
Inspiring
December 13, 2021
Answered

Is it possible to set "responsive off" when exporting SVG of illustrator CC series with javascript?

  • December 13, 2021
  • 2 replies
  • 2534 views

Hello All!

 

I'm an engineer writing a javascript program. I'm Japanese, but I'm not good at English, so I use google translate.

 

In older versions of illustrator, there was no control of responsive settings when controlling SVG output with javascript. However, in the CC series version, you can switch the responsive setting when manually outputting SVG. Can this be controlled from javascript?

 

My problem is that I can't turn off the responsive setting when I want to turn it off when outputting SVG.

 

However, as far as I know, there should be no commands that can manipulate responsive settings.

 

可能であれば、javascriptのソースコードの再編集だけで完了させたいが、難しい為、解決方法を探しています。

This topic has been closed for replies.
Correct answer MSAII

if that does not work, there's a newer method to export to svg that has a responsive property, see the threads below

 

https://community.adobe.com/t5/illustrator-discussions/scripting-svg-export-quot-object-ids-quot-and-quot-responsive-quot-settings/m-p/12660514#M306069

 

https://community.adobe.com/t5/illustrator-discussions/new-export-to-svg-illustrator-19-2-2015-1/m-p/7863742#M219435

 


Thank you CarlosCanto.

 

Thanks to you, the problem has been solved.

The bottom line is that the functions used inside the script were outdated, not the application preferences.

 

I have already found the location of the configuration file you provided.

However, after changing the settings in this file, restarting the PC did not solve the problem. illustrator may not have read this preference file correctly.

 

Then I referred to the other agenda reports you presented. There was a correct answer in the first report.

 

The settings I was using to export SVG are

 

// Save as SVG
sourceDoc.exportFile(targetFile, ExportType.SVG, this.getMyOptionsSVG());

 

//***SVG Option

function getMyOptionsSVG(){
var options = new ExportOptionsSVG();
options.DTD = SVGDTDVersion.SVG1_1;

options.cssProperties = SVGCSSPropertyLocation.PRESENTATIONATTRIBUTES;
return options;
}

 

However, this function has been available since the days of CS4.

A new function was implemented. In order to correspond to that function, the following modifications have been made.

 

// Save as SVG
sourceDoc.exportFile(targetFile, ExportType.WOSVG, this.getMyOptionsSVG());

 

//***SVG Option

function getMyOptionsSVG(){
var options = new ExportOptionsWebOptimizedSVG();
options.DTD = SVGDTDVersion.SVG1_1;

options.cssProperties = SVGCSSPropertyLocation.PRESENTATIONATTRIBUTES;

options.svgResponsive = false;
return options;
}

 

I woke up from this nightmare.

Thank you for your cooperation.

 

2 replies

CarlosCanto
Community Expert
Community Expert
December 13, 2021

there's a preference setting you can turn on/off

 

// turn off Responsive SVG preference

// https://community.adobe.com/t5/illustrator-discussions/is-it-possible-to-set-quot-responsive-off-quot-when-exporting-svg-of-illustrator-cc-series-with/td-p/12589330

app.preferences.setBooleanPreference ("plugin/svgOptionDlg/O_ResponsiveSVG", false);
Community Expert
March 30, 2022

Carlos, thank you very much!

That saved my day ( and my sanity as well ) .

 

Additionally:

We should always know what the user checked the last time when saving as SVG so that we can revert to the user's setting after our code is executed. That would be possible with getBooleanPreference() on the preferences of the application:

 

var currentStateOfResponsiveProperty = 
app.preferences.getBooleanPreference( "plugin/svgOptionDlg/O_ResponsiveSVG" );

 

Thanks a lot!

Uwe Laubender

( ACP )

CarlosCanto
Community Expert
Community Expert
March 30, 2022

Glad to help Uwe!

MSAII
MSAIIAuthor
Inspiring
December 13, 2021

(Sorry, I accidentally posted a Japanese text, so I will write a translation.)

 

If possible, I would like to complete it by just re-editing the javascript source code, but it is difficult, so I am looking for a solution.