SVG batch: where to add resize artboard code ?
I wish to include a part of code to get artboard resized and then convert .eps and .ai to SVG files.
Not sure where it should go ?
Any clues, let me know
THANKS GUYS !!
------------------------------
// artboard resize code
for (i=0; i < filesToProcess.length; i++) {
app.open(filesToProcess);
var doc = app.activeDocument;
var myBorder = 10; // Set to width of border desired, in points
var myVisibleBounds = doc.visibleBounds; // Rect, which is an array;
myVisibleBounds[0] -= myBorder; // left coordinate (use negative values to add artboard)
myVisibleBounds[1] += myBorder; // top coordinate
myVisibleBounds[2] += myBorder; // right coordinate
myVisibleBounds[3] -= myBorder; // bottom coordinate (use negative values to add artboard)
doc.artboards[0].artboardRect = myVisibleBounds;
-----------------------
WHERE TO PUT IT IN THE SVG BATCH CODE ??
----------------------
// Main Code [Execution of script begins here]
var destFolder, sourceFolder, files, fileType, sourceDoc, targetFile, svgSaveOpts;
// Select the source folder.
sourceFolder = Folder.selectDialog( 'Select the folder with Illustrator files you want to convert to SVG', '~' );
// If a valid folder is selected
if ( sourceFolder != null )
{
files = new Array();
filesToProcess = sourceFolder.getFiles("*.ai","*.eps");
// Get all files matching the pattern
files = sourceFolder.getFiles( fileType );
if ( files.length > 0 )
{
// Get the destination to save the files
destFolder = Folder.selectDialog( 'Select the folder where you want to save the converted SVG files.', '~' );
for ( i = 0; i < files.length; i++ )
{
sourceDoc = app.open(files); // returns the document object
// Call function getNewName to get the name and file to save the SVG
targetFile = getNewName();
// Call function getSVGOptions get the SVGSaveOptions for the files
svgSaveOpts = getSVGOptions( );
// Save as svg
sourceDoc.exportFile(targetFile, ExportType.SVG, svgSaveOpts );
sourceDoc.close();
}
alert( 'Files are saved as SVG in ' + destFolder );
}
else
{
alert( 'No matching files found' );
}
}
/*********************************************************
getNewName: Function to get the new file name. The primary
name is the same as the source file.
**********************************************************/
function getNewName()
{
var ext, docName, newName, saveInFile, docName;
docName = sourceDoc.name;
ext = '.svg'; // new extension for svg file
newName = "";
for ( var i = 0 ; docName != "." ; i++ )
{
newName += docName;
}
newName += ext; // full svg name of the file
// Create a file object to save the svg
saveInFile = new File( destFolder + '/' + newName );
return saveInFile;
}
function getSVGOptions()
{
var svgSaveOpts = new ExportOptionsSVG();
l
svgSaveOpts.embedRasterImages = true;
return svgSaveOpts;
}