Skip to main content
Legend
November 21, 2021
Answered

Script for ExportForScreensOptionsJPEG() not working.

  • November 21, 2021
  • 2 replies
  • 1797 views

Hello,

 

I've been trying to get the below code to work from the post below, but I just can't figure it out....any ideas??

Error Code# 1200: an Illustrator error occurred: 1128353364 ('TNAC') @ file

https://community.adobe.com/t5/illustrator-discussions/export-for-screens-exporting-multiple-documents/td-p/9400860

 

var doc = app.documents[0];

var myFolder = activeDocument.path;

var assets = doc.assets; 

var whatToExport = new ExportForScreensItemToExport();

whatToExport.artboards = '1-2';

whatToExport.document = true;

var jpegParam = new ExportForScreensOptionsJPEG();

jpegParam.compressionMethod = JPEGCompressionMethodType.PROGRESSIVE;

jpegParam.progressiveScan = 4;

jpegParam.antiAliasing = AntiAliasingMethod.None;

jpegParam.embedICCProfile = true;

jpegParam.scaleType = ExportForScreensScaleType.SCALEBYWIDTH;

jpegParam.scaleTypeValue = 400;

path = new File(myFolder + "/" + "_thumbs" + ".jpg");

doc.exportForScreens(path, ExportForScreensType.SE_JPEG100, jpegParam, whatToExport, "JPEG100_");

 

 

Thanks in advance!

Regards,

Mike

 

This topic has been closed for replies.
Correct answer Charu Rajput

Hi Mike,

Try the following script it will work

var doc = app.documents[0];
var myFolder = activeDocument.path;
var assets = doc.assets;
var whatToExport = new ExportForScreensItemToExport();
whatToExport.artboards = '1-2';
whatToExport.document = true;
var jpegParam = new ExportForScreensOptionsJPEG();
jpegParam.compressionMethod = JPEGCompressionMethodType.PROGRESSIVE;
jpegParam.progressiveScan = 4;
jpegParam.antiAliasing = AntiAliasingMethod.None;
jpegParam.embedICCProfile = true;
jpegParam.scaleType = ExportForScreensScaleType.SCALEBYWIDTH;
jpegParam.scaleTypeValue = 400;
var path1 = new File(myFolder + "/" + "_thumbs" + ".jpg");
doc.exportForScreens(path1, ExportForScreensType.SE_JPEG100, jpegParam, whatToExport);

 

The error that you have received may be of the following reasons

1. You don't have 2 artboards in the document as you mention artboards="1-2". Make sure to have two artboards.

2. Last parameter in the exportForScreens is not required.

 

I hope it help you.

2 replies

m1b
Community Expert
Community Expert
March 4, 2023

Hi all, I know this is an old thread, but I just got this exact same 'TNAC' error while using ExportForScreens. The reason for the error is that scaleTypeValue = 400 is out-of-bounds. ScaleTypeValue is a simple scale factor, so if you want 400% scale, use scaleTypeValue = 4.

- Mark

Charu Rajput
Community Expert
Charu RajputCommunity ExpertCorrect answer
Community Expert
November 21, 2021

Hi Mike,

Try the following script it will work

var doc = app.documents[0];
var myFolder = activeDocument.path;
var assets = doc.assets;
var whatToExport = new ExportForScreensItemToExport();
whatToExport.artboards = '1-2';
whatToExport.document = true;
var jpegParam = new ExportForScreensOptionsJPEG();
jpegParam.compressionMethod = JPEGCompressionMethodType.PROGRESSIVE;
jpegParam.progressiveScan = 4;
jpegParam.antiAliasing = AntiAliasingMethod.None;
jpegParam.embedICCProfile = true;
jpegParam.scaleType = ExportForScreensScaleType.SCALEBYWIDTH;
jpegParam.scaleTypeValue = 400;
var path1 = new File(myFolder + "/" + "_thumbs" + ".jpg");
doc.exportForScreens(path1, ExportForScreensType.SE_JPEG100, jpegParam, whatToExport);

 

The error that you have received may be of the following reasons

1. You don't have 2 artboards in the document as you mention artboards="1-2". Make sure to have two artboards.

2. Last parameter in the exportForScreens is not required.

 

I hope it help you.

Best regards
Mike BroAuthor
Legend
November 21, 2021

@Charu Rajput,

 

Thank you! I'm not sure why it wasn't working as the document has 2 artboards and I tried removing the Last parameter in the exportForScreens, but it's working now.

Question: do you know why the "_thumbs" that's hard coded for the output file naming wouldn't be honored?? I had to create a work around by having the script rename the artboards before the export and rename the back afterwards.

 

Regards,

Mike

Charu Rajput
Community Expert
Community Expert
November 23, 2021

Hi Mike,

exportForScreens expect first parameter as exportFolder, where assets will be exported, that's why it won't consider _thumb.jpg name. But you can add the suffix to the exporte file by passing the string as a last parameter. See below code.

var doc = app.documents[0];
var myFolder = activeDocument.path;
var assets = doc.assets;
var whatToExport = new ExportForScreensItemToExport();
whatToExport.artboards = '1-2';
whatToExport.document = true;
var jpegParam = new ExportForScreensOptionsJPEG();
jpegParam.compressionMethod = JPEGCompressionMethodType.PROGRESSIVE;
jpegParam.progressiveScan = 4;
jpegParam.antiAliasing = AntiAliasingMethod.None;
jpegParam.embedICCProfile = true;
jpegParam.scaleType = ExportForScreensScaleType.SCALEBYWIDTH;
jpegParam.scaleTypeValue = 400;
var path1 = new File(myFolder);
doc.exportForScreens(path1, ExportForScreensType.SE_JPEG100, jpegParam, whatToExport, '_thumb_');

 

So, whatever will be exported from the above script will have _thumb_ as a prefix to the exported file.

Best regards