Copy link to clipboard
Copied
I'm trying to create a code that selects the whole artboard and drags it to the Asset Export to save them as svg and png. Is it possible?
Hi @placeit_1800, here is a script I wrote last year that export in various formats. Perhaps you will learn something that will help. You need to edit it to suit your needs, in particular the export paths.
- Mark
/**
* Export For Screens in various formats.
* @author m1b
* @version 2023-03-05
* @discussion https://community.adobe.com/t5/illustrator-discussions/script-for-export-multiple-artboard-to-jpg-png-etc/m-p/13624982
*/
(function () {
var exportPathJPG = '~/Desktop/EXPORTS/JPG/
...
Copy link to clipboard
Copied
Hi @placeit_1800, here is a script I wrote last year that export in various formats. Perhaps you will learn something that will help. You need to edit it to suit your needs, in particular the export paths.
- Mark
/**
* Export For Screens in various formats.
* @author m1b
* @version 2023-03-05
* @discussion https://community.adobe.com/t5/illustrator-discussions/script-for-export-multiple-artboard-to-jpg-png-etc/m-p/13624982
*/
(function () {
var exportPathJPG = '~/Desktop/EXPORTS/JPG/',
exportPathPNG = '~/Desktop/EXPORTS/PNG/',
exportPathSVG = '~/Desktop/EXPORTS/SVG/',
exportPathPDF = '~/Desktop/EXPORTS/PDF/';
// Check if a document is open
if (app.documents.length == 0) {
alert("No open document.");
return;
}
var previousInteractionLevel = app.userInteractionLevel;
app.userInteractionLevel = UserInteractionLevel.DONTDISPLAYALERTS;
var doc = app.activeDocument;
// do the exporting
exportJPG(doc, File(exportPathJPG));
exportPNG(doc, File(exportPathPNG));
exportPDF(doc, File(exportPathPDF));
exportSVG(doc, File(exportPathSVG));
// clean up
app.userInteractionLevel = previousInteractionLevel;
// display a confirmation message
alert("Export complete.");
/**
* Export all artboards as PNG.
* @param {Document} doc - an Illustrator Document.
* @param {Folder} [exportFolder] - the folder to export to (default: document's folder).
*/
function exportPNG(doc, exportFolder) {
var options = new ExportForScreensOptionsPNG24();
options.antiAliasing = AntiAliasingMethod.ARTOPTIMIZED;
options.scaleType = ExportForScreensScaleType.SCALEBYFACTOR;
options.scaleTypeValue = 1;
options.transparency = true;
var itemToExport = new ExportForScreensItemToExport();
itemToExport.artboards = 'all';
itemToExport.document = false;
exportFolder = exportFolder || doc.path;
doc.exportForScreens(exportFolder, ExportForScreensType.SE_PNG24, options, itemToExport);
};
/**
* Export all artboards as JPG.
* @param {Document} doc - an Illustrator Document.
* @param {Folder} [exportFolder] - the folder to export to (default: document's folder).
*/
function exportJPG(doc, exportFolder) {
var options = new ExportForScreensOptionsJPEG();
options.antiAliasing = AntiAliasingMethod.ARTOPTIMIZED;
options.compressionMethod = JPEGCompressionMethodType.BASELINESTANDARD;
options.embedICCProfile = false;
options.scaleType = ExportForScreensScaleType.SCALEBYFACTOR;
options.scaleTypeValue = 1;
var itemToExport = new ExportForScreensItemToExport();
itemToExport.artboards = 'all';
itemToExport.document = false;
exportFolder = exportFolder || doc.path;
doc.exportForScreens(exportFolder, ExportForScreensType.SE_JPEG100, options, itemToExport);
};
/**
* Export all artboards as PDF.
* @param {Document} doc - an Illustrator Document.
* @param {Folder} [exportFolder] - the folder to export to (default: document's folder).
*/
function exportPDF(doc, exportFolder) {
var options = new ExportForScreensPDFOptions();
options.pdfPreset = '[Press Quality]';
var itemToExport = new ExportForScreensItemToExport();
itemToExport.artboards = 'all';
itemToExport.document = false;
doc.exportForScreens(exportFolder, ExportForScreensType.SE_PDF, options, itemToExport);
};
/**
* Export all artboards as SVG.
* @param {Document} doc - an Illustrator Document.
* @param {Folder} [exportFolder] - the folder to export to (default: document's folder).
*/
function exportSVG(doc, exportFolder) {
var options = new ExportForScreensOptionsWebOptimizedSVG();
options.coordinatePrecision = 3;
options.cssProperties = SVGCSSPropertyLocation.ENTITIES;
options.fontType = SVGFontType.OUTLINEFONT;
options.rasterImageLocation = RasterImageLocation.EMBED;
options.svgId = SVGIdType.SVGIDREGULAR;
options.svgMinify = false;
options.svgResponsive = true;
var itemToExport = new ExportForScreensItemToExport();
itemToExport.artboards = 'all';
itemToExport.document = false;
doc.exportForScreens(exportFolder, ExportForScreensType.SE_SVG, options, itemToExport);
};
})();
Copy link to clipboard
Copied
Thank m1b!
In the end I used