Copy link to clipboard
Copied
Hello everyone,
I need some help. I am trying to generate a JSX to automatically export the artboards of an Illustrator document to TIFF (I have three artboards within the same document, and I am trying to export two separate images to two TIFF files) and save them to a specific folder.
I've done this, but it's not working properly and I don't know where the error is.
Can anyone help me??? Thaaanks 🙂
var doc = app.activeDocument;
var f = new Folder("~/Desktop/JPG PDF"); f.create();
var activeLayers = doc.artboards.setActiveArtboardIndex(0);
doc.activeLayer = doc.layers.getByName('AN');
//export front
var docPath="~/Desktop/JPG PDF/";
var docName='';
docName = activeDocument.name;
//app.activeDocument.artboards.serActiveArtboardIndex(1);
var NewName = docName.replace(" - IMPRESORAS ","MED");
var NewName2 = NewName.replace(".ai","");
var NewName22 = "_AN.tiff"
var NewName3 = "docPath"+"NewName"+"NewName2"+"NewName22"
//exportFileToJPEG('~/Desktop/m300.jpg');
exportFileToTIFF(docPath+NewName2+NewName22);
function exportFileToTIFF (dest)
{
if ( app.documents.length > 0 )
{
var exportOptions = new ExportOptionsTIFF();
var type = ExportType.TIFF;
var fileSpec = new File(dest);
//exportOptions.antiAliasing = false;
exportOptions.artBoardClipping = true;
exportOptions.horizontalScale = 416.667/2; // 416.667=300ppp
exportOptions.verticalScale = 416.667/2;
exportOptions.qualitySetting = 100;
app.activeDocument.exportFile( fileSpec, type, exportOptions );
}
}
//Export back
var doc = app.activeDocument;
var docPath="~/Desktop/JPG PDF/";
var docName='';
docName = activeDocument.name;
var activeLayers = doc.artboards.setActiveArtboardIndex(1);
doc.activeLayer = doc.layers.getByName('RE');
var NewName = docName.replace(" - IMPRESORAS ","MED");
var NewName2 = NewName.replace(".ai","");
var NewName22 = "_RE.tiff"
var NewName3 = "docPath"+"NewName"+"NewName2"+"NewName22"
//exportFileToJPEG('~/Desktop/m300.jpg');
exportFileToTIFF(docPath+NewName2+NewName22);
function exportFileToTIFF (dest)
{
if ( app.documents.length > 0 )
{
var exportOptions = new ExportOptionsTIFF();
var type = ExportType.TIFF;
var fileSpec = new File(dest);
//exportOptions.antiAliasing = false;
exportOptions.artBoardClipping = true;
exportOptions.horizontalScale = 416.667/2; // 416.667=300ppp
exportOptions.verticalScale = 416.667/2;
exportOptions.qualitySetting = 100;
app.activeDocument.exportFile( fileSpec, type, exportOptions );
}
}
If you want to export artboards by index, setting the names of the exported files. After your screenshot, I'm still not sure if I understand the task correctly. Perhaps you still wanted to export the layers.
(function (){
var docName = app.activeDocument.name;
var folder = new Folder("~/Desktop/TIFF");
folder.create();
var newName = docName.replace(".ai", "").replace(" - IMPRESORAS ", "MED");
exportToTIFF(folder + "/" + newName + "_AN.tiff", 0); // File path and artboard index: 0, 1, ...
Copy link to clipboard
Copied
You have a lot of errors in the code, from which it is not yet clear what exactly you want. In the task, you describe the artboards, but in the code you activate both the artboards by index and the layers by name. Could you show us screenshots of the document and tell us in more detail what exactly you want to export to TIFF? Are the artboards or the contents of the layers, or are the contents of the layers cropped by the artboard?
Copy link to clipboard
Copied
Hi, I'm sorry, I'm new to this. 🙂
I think I've included more than is actually necessary. The idea would be to export the two worksheets in the document in TIFF format, but as two separate TIFF images with specific names. I would like them to be saved in a specific folder on my desktop.
Thanks 😄
Copy link to clipboard
Copied
Can't you just export as .tif, use the Use Artboards option and set your desired range in the regular Export dialog?
Copy link to clipboard
Copied
Yes, but it's something I have to do repeatedly and with the same characteristics, so I was hoping to write a script to speed up the process. 🙂
Copy link to clipboard
Copied
If you want to export artboards by index, setting the names of the exported files. After your screenshot, I'm still not sure if I understand the task correctly. Perhaps you still wanted to export the layers.
(function (){
var docName = app.activeDocument.name;
var folder = new Folder("~/Desktop/TIFF");
folder.create();
var newName = docName.replace(".ai", "").replace(" - IMPRESORAS ", "MED");
exportToTIFF(folder + "/" + newName + "_AN.tiff", 0); // File path and artboard index: 0, 1, 2...
exportToTIFF(folder + "/" + newName + "_RE.tiff", 1); // File path and artboard index: 0, 1, 2...
removeIndexFromFile(folder);
function exportToTIFF(dest, index) {
if (app.documents.length === 0) return;
var fileSpec = new File(dest);
var exportOptions = new ExportOptionsTIFF();
var type = ExportType.TIFF;
exportOptions.saveMultipleArtboards = true;
exportOptions.artboardRange = (index < 9 ? '0' : '') + (index + 1).toString();
exportOptions.embedICCProfile = false; // ExtendScript bug, the color profile won't embed in any case
exportOptions.imageColorSpace = ImageColorSpace.RGB; // ImageColorSpace.CMYK
exportOptions.resolution = 300; // DPI
exportOptions.byteOrder = TIFFByteOrder.IBMPC;
app.activeDocument.exportFile(fileSpec, type, exportOptions);
}
function removeIndexFromFile(folder) {
var files = folder.getFiles("*.tiff");
files = files.concat(folder.getFiles("*.tif"));
for (var i = 0; i < files.length; i++) {
var file = files[i];
var fileName = file.name;
if (fileName.match(/-\d{2}\.(tiff|tif)$/i)) {
var newFileName = fileName.replace(/-\d{2}(?=\.(tiff|tif)$)/i, "");
file.rename(newFileName);
}
}
}
})();
Copy link to clipboard
Copied
Ohhh... it's great, it works perfectly... it's just what I wanted.
Thanks a lot 😄 i'm happy
Find more inspiration, events, and resources on the new Adobe Community
Explore Now