Copy link to clipboard
Copied
This code is so simple yet is not working, it is even an example from the scripting pdf:
//------------------------------------------------------------------------
//------------------------------------------------------------------------
var svgOpt = new ExportOptionsSVG();
svgOpt.SVGFontType = 'SVGFONT';
svgOpt.SVGDTDVersion = 'SVG1_0';
svgOpt.SVGCSSPropertyLocation = 'Entities';
var fileSpec = new File("~/sample.svg");
//-------------------------------------------------------------------------------
if (app.documents.length > 0)
{
app.activeDocument.exportFile(fileSpec, ExportType.SVG, svgOpt);
alert("file exported");
}
else
{
alert("file NOT exported");
}
//------------------------------------------------------------------------
//------------------------------------------------------------------------
It gives me the prompt that a file was exported however no file is generated. Does anyone have a suggestion?
Thanks!
Copy link to clipboard
Copied
Ok, I got the file to export, BUT the SVG export options are being ignored. The SVG is exported as version 1.1 even though it is scripted to export as version 1.0. This is a very important requirement for these SVG's.
Any idea why this is happening?
Script is here:
aiFolder = Folder.selectDialog ('Select folder to search through');
var svgOpt = new ExportOptionsSVG();
svgOpt.SVGFontType = 'SVGFONT';
svgOpt.SVGDTDVersion = 'SVG1_0';
svgOpt.SVGCSSPropertyLocation = 'ENTITIES';
//var fileSpec = new File("~/sample.svg");
//-------------------------------------------------------------------------------
if (app.documents.length > 0)
{
app.activeDocument.exportFile(aiFolder, ExportType.SVG, svgOpt);
alert("file exported");
}
else
{
alert("file NOT exported");
}
//sourceDoc.saveAs(aiFolder, aiOpt);
//app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
Thanks
Copy link to clipboard
Copied
Loose the quotes around the properties, I.e. SVGFONT, SVG1_0, ENTITIES.
Copy link to clipboard
Copied
Thanks for the quick response, unfortunately it does not work.
I tried without the quotes:
svgOpt.SVGFontType = SVGFONT;
svgOpt.SVGDTDVersion = SVG1_0;
svgOpt.SVGCSSPropertyLocation = ENTITIES;
but I get an error:
"SVGFONT is undefined"
Copy link to clipboard
Copied
Thanks for the suggestion, I got it to work. I had the option declarations wrong as well.
This works perfectly now:
var svgOpt = new ExportOptionsSVG();
svgOpt.fontType = SVGFontType.SVGFONT;
svgOpt.DTD = SVGDTDVersion.SVG1_0;
svgOpt.cssProperties = SVGCSSPropertyLocation.ENTITIES;
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more