Skip to main content
Inspiring
January 5, 2023
Question

Save file in multiple formats and diifferent ppi

  • January 5, 2023
  • 3 replies
  • 310 views

Hello everybody, hope y'all doing awesome!

 

Can anybody help me with a script to save / export a file in multiple formats, ppi, modes and with/without artboard?

I know I can do it with actions but whenever I move that action pack to another PC there will be an issue with the user directory, mine will be my name/desktop for example and in other computer will be different.

 

I need to:

 

Save as EPS file

Export JPG in RGB mode 300ppi

Export PNG in CMYK mode 360ppi

Export TIFF in CMYK mode 360ppi

 

if possible I would like to be able to choose (in the code, customizable) which file I want to be exported with or without the artboards.

 

Thank you so much.

 

 

This topic has been closed for replies.

3 replies

Inspiring
January 9, 2023

Update, I just started using this code I made, working so far but I don't know how to export multiple artboards (in one open tab only)  or multiple files (with only one artboard in each tab). I'll appreaciate some help. Thankks

Inspiring
January 5, 2023

I got something but I dont know how to export  using the artboards, maybe I should create a square of something of the same size as the artboard? well here is my code:

 

function ExportAll() {
//Ask for location and name of the files
var _location = Folder.selectDialog("Select location");
var fileName = prompt('Please enter file name:', fileName);

//Set my new files names
var newFile = new File(_location + "/" + fileName + '.eps');

//My active document is my file about to save (saveDoc)
var saveDoc;
if (app.documents.length == 0) {
saveDoc = app.documents.add();
} else {
saveDoc = app.activeDocument;
}

//Set document to CMYK
app.executeMenuCommand("doc-color-cmyk");

//If doc exist continue, create EPS options
var saveOpts = new EPSSaveOptions();
saveOpts.cmykPostScript = true;
saveOpts.embedAllFonts = true;
saveDoc.saveAs(newFile, saveOpts); // EPS already created

//Change to RGB
app.executeMenuCommand("doc-color-rgb");

// start of JPG in RGB 300ppi
var JPGExportOpt = new ImageCaptureOptions();
JPGExportOpt.antiAliasing = true;
JPGExportOpt.resolution = 300;
var fileSpec = new File(_location + "/" + fileName + '.jpg');
app.activeDocument.imageCapture(fileSpec, app.activeDocument.geometricBounds, JPGExportOpt);

//Change to CMYK
app.executeMenuCommand("doc-color-cmyk");

//Export as PNG in CMYK at 360ppi
var PNGExportOpt = new ImageCaptureOptions();
PNGExportOpt.antiAliasing = true;
PNGExportOpt.resolution = 360;
PNGExportOpt.transparency = true;
fileSpec = new File(_location + "/" + fileName + '.png');
app.activeDocument.imageCapture(fileSpec, app.activeDocument.geometricBounds, PNGExportOpt);

//Export as TIFF in CMYK at 360ppi
var TIFExportOpt = new ImageCaptureOptions();
TIFExportOpt.antiAliasing = true;
TIFExportOpt.resolution = 360;
fileSpec = new File(_location + "/" + fileName + '.tif');
app.activeDocument.imageCapture(fileSpec, app.activeDocument.geometricBounds, TIFExportOpt);
}

ExportAll();

Inspiring
January 5, 2023

by the way, I know I can save the user's directory choice by using something like:

 

var _location = Folder.selectDialog("Select location");
var fileName = prompt('Please enter file name:', fileName);
// alert(_location);
var pdfFile = new File(_location + "/" + fileName + '.pdf');

 

So i will not need to ask him everytime per save/export file , hope you can find this useful!