Scripting SVG Export: "Object IDs" and "Responsive" settings

Community Beginner ,
Jan 14, 2022 Jan 14, 2022

Copy link to clipboard

Copied

We're exporting some documents as SVGs using scripting, and are trying to match the export settings we use via the UI. The settings we need are:

Capture.PNG
But using the ExportOptionsSVG settings in our script, it seems that we're unable to set the "Object IDs" or "Responsive" settings to our required values.

Does anyone know if this is possible? We're looking into potentially using dynamic actions from our script, but this seems heavy-handed for what should just be some simple settings!

Also, are these the most up-to-date docs for the various API functions? Or are there some other official docs that we're missing somewhere?

TOPICS
Import and export , Scripting

Views

424

Likes

Translate

Translate

Report

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

correct answers 1 Correct answer

Community Beginner , Jan 14, 2022 Jan 14, 2022
We've made some progress with this. It turns out that there is also ExportOptionsWebOptimizedSVG and ExportType.WOSVG that we can use. This option class does have the svgResponsive property which seems to do what we need. It also seems to be doing "Object IDs = Layer Names" by default. We pieced this together from some info in this post as well as some related docs for the ExportForScreensOptionsWebOptimizedSVG object buried in this post . So the question now is, is this a valid approach or is...

Likes

Translate

Translate
Community Beginner ,
Jan 14, 2022 Jan 14, 2022

Copy link to clipboard

Copied

We've made some progress with this. It turns out that there is also ExportOptionsWebOptimizedSVG and ExportType.WOSVG that we can use. This option class does have the svgResponsive property which seems to do what we need. It also seems to be doing "Object IDs = Layer Names" by default.

We pieced this together from some info in this post as well as some related docs for the ExportForScreensOptionsWebOptimizedSVG object buried in this post .

So the question now is, is this a valid approach or is there some reason we shouldn't be using these undocumented settings?

cc @CarlosCanto here because you published the "What's New in Illustrator Scripting CC2018" post mentioned above. Thoughts?

Likes

Translate

Translate

Report

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 ,
Jan 14, 2022 Jan 14, 2022

Copy link to clipboard

Copied

Working export code for reference:

function exportFileAsSvg(path) {
    const options = new ExportOptionsWebOptimizedSVG();
    options.compressed = false;
    options.coordinatePrecision = 3;
    options.cssProperties = SVGCSSPropertyLocation.PRESENTATIONATTRIBUTES;
    options.fontSubsetting = SVGFontSubsetting.None;
    options.fontType = SVGFontType.SVGFONT;
    options.svgResponsive = false;

    app.activeDocument.exportFile(new File(path), ExportType.WOSVG, options);
}

exportFileAsSvg("X:\\foo.svg")

Likes

Translate

Translate

Report

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 Professional ,
Jan 14, 2022 Jan 14, 2022

Copy link to clipboard

Copied

Hi @Ben Vosper, here's a link to ExportOptionsWebOptimizedSVG and ExportForScreensOptionsWebOptimizedSVG. Bookmark this site for latest API entries (you'll need the current one also—this only has the new stuff).

- Mark

Likes

Translate

Translate

Report

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 ,
Jan 14, 2022 Jan 14, 2022

Copy link to clipboard

Copied

@m1bAmazing, thanks! Are these docs you maintain yourself or are they an offical Adobe resource? Just wondering if they're linked from anywhere!

Likes

Translate

Translate

Report

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 Professional ,
Jan 14, 2022 Jan 14, 2022

Copy link to clipboard

Copied

No I don't maintain them and they aren't official adobe. I only just found the site thanks to CarlosCanto! Thank you Carlos!

 - Mark

Likes

Translate

Translate

Report

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 Professional ,
Jan 14, 2022 Jan 14, 2022

Copy link to clipboard

Copied

I think Charu or Femke posted that link Mark. I posted the official guides at the new https://developer.adobe.com/

Likes

Translate

Translate

Report

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 Professional ,
Jan 14, 2022 Jan 14, 2022

Copy link to clipboard

Copied

Likes

Translate

Translate

Report

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
Advocate ,
Jan 14, 2022 Jan 14, 2022

Copy link to clipboard

Copied

Also, to give credit where credit is due, I believe this is based on Jongware's old website. 

Likes

Translate

Translate

Report

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 Professional ,
Jan 14, 2022 Jan 14, 2022

Copy link to clipboard

Copied

Exactly @femkeblanco Jongware's was the first I ever saw.

Likes

Translate

Translate

Report

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 Professional ,
Jan 15, 2022 Jan 15, 2022

Copy link to clipboard

Copied

you might be correct @femkeblanco, I also remember jongware's being the first, or at least the first I saw.

Likes

Translate

Translate

Report

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 Professional ,
Jan 14, 2022 Jan 14, 2022

Copy link to clipboard

Copied

Oops! @mikeb41294032 thanks for the useful post! - Mark

Likes

Translate

Translate

Report

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 Professional ,
Mar 30, 2022 Mar 30, 2022

Copy link to clipboard

Copied

LATEST

Just to make it clear for readers here who did not read into the links Mark offers. This was done by Gregor Fellenz.  Currently it's showing the state of the DOM of Illustrator version 25:

https://www.indesignjs.de/extendscriptAPI/illustrator-latest/#about.html

 

Regards,
Uwe Laubender

( ACP )

Likes

Translate

Translate

Report

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 Professional ,
Jan 14, 2022 Jan 14, 2022

Copy link to clipboard

Copied

Glad to see you found your own answer Ben

Likes

Translate

Translate

Report

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