Copy link to clipboard
Copied
Refer to the script code below and modify it to export jpg to the current ai file path. Export according to the drawing board. Resolution 150
var pngPath = activeDocument.fullName.toString();
pngPath = pngPath.substring(0,pngPath.lastIndexOf("."));
exportFileToPNG24(pngPath);
function exportFileToPNG24 (dest) {
if ( app.documents.length > 0 ) {
var exportOptions = new ExportOptionsPNG24();
var type = ExportType.PNG24;
var fileSpec = new File(dest);
exportOptions.antiAliasing = false;
exportOptions.transparency = false;
exportOptions.artBoardClipping = true;
exportOptions.saveAsHTML = true;
app.activeDocument.exportFile( fileSpec, type, exportOptions );
}
}
if ( app.documents.length > 0 ) {
var doc = app.activeDocument;
for(i=0;i<doc.artboards.length;i++){
var pngPath = activeDocument.fullName.toString();
pngPath = pngPath.substring(0,pngPath.lastIndexOf("."))+doc.artboards[i].name;
doc.artboards.setActiveArtboardIndex(i);
exportFileToPNG24(pngPath);
}
function exportFileToPNG24 (dest) {
var exportOptions = new ExportOptionsPNG24();
var type = ExportType.PNG24;
var fileSpec = new File(dest);
exportOptions.antiAliasing = false;
exportOptions.transparency = false;
exportOptions.artBoardClipping = true;
exportOptions.saveAsHTML = true;
app.activeDocument.exportFile( fileSpec, type, exportOptions );
}
}
Hi,
To add more information, imageCapture only works to export into PNG format. For JPEg, please refer the link below
https://community.adobe.com/t5/illustrator/export-jpg-as-300-ppi/m-p/11244323?page=1#M183146
Copy link to clipboard
Copied
Hello,
the script does not know how to set DPI
you can call a third-party utility
or call Action (but there are subtleties)
var pngPath = activeDocument.fullName.toString();
pngPath = pngPath.substring(0,pngPath.lastIndexOf("."));
exportFileToJPEG(pngPath);
function exportFileToPNG24 (dest) {
if ( app.documents.length > 0 ) {
var exportOptions = new ExportOptionsPNG24();
var type = ExportType.PNG24;
var fileSpec = new File(dest);
exportOptions.antiAliasing = false;
exportOptions.transparency = false;
exportOptions.artBoardClipping = true;
exportOptions.saveAsHTML = true;
app.activeDocument.exportFile( fileSpec, type, exportOptions );
}
}
function exportFileToJPEG (dest) {
if ( app.documents.length > 0 ) {
var exportOptions = new ExportOptionsJPEG();
var type = ExportType.JPEG;
var fileSpec = new File(dest);
exportOptions.antiAliasing = false;
exportOptions.qualitySetting = 100;
exportOptions.horizontalScale = 100;
exportOptions.verticalScale = 100;
exportOptions.artBoardClipping = true;
app.activeDocument.exportFile( fileSpec, type, exportOptions );
}
}
if ( app.documents.length > 0 ) {
var doc = app.activeDocument;
for (i = 0; i < doc.artboards.length; i++) {
var pngPath = activeDocument.fullName.toString();
pngPath = pngPath.substring(0, pngPath.lastIndexOf(".")) + doc.artboards[i].name;
doc.artboards.setActiveArtboardIndex(i);
exportFileToJPEG(pngPath);
}
}
Copy link to clipboard
Copied
Hello, thank you very much for your help. It would be great if you can set up DIP or who would hope to help me. Thank you very much
Copy link to clipboard
Copied
Here is another post with answer how to set dpi settings.
So your code will be something like this:
if ( app.documents.length > 0 ) {
for (i = 0; i < doc.artboards.length; i++) {
var Path = activeDocument.fullName.toString();
Path = Path.substring(0, Path.lastIndexOf(".")) + doc.artboards[i].name + ".jpg";
doc.artboards.setActiveArtboardIndex(i);
var activeAB = doc.artboards[doc.artboards.getActiveArtboardIndex()];
exportFile(Path);
}
}
function exportFile (dest) {
var exportOptions = new ImageCaptureOptions();
var fileSpec = new File(dest);
exportOptions.antiAliasing = true;
exportOptions.resolution = 150;
doc.imageCapture( fileSpec, activeAB.artboardRect, exportOptions );
}
Copy link to clipboard
Copied
Thank you
Copy link to clipboard
Copied
Hi,
To add more information, imageCapture only works to export into PNG format. For JPEg, please refer the link below
https://community.adobe.com/t5/illustrator/export-jpg-as-300-ppi/m-p/11244323?page=1#M183146