Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Convert AI files to PSD, PDF, JPEG or PNG Image Format Programmatically in Java
String dataDir = Utils.getDataDir(AIToJPG.class) + "AI/";
String sourceFileName = dataDir + "34992OStroke.ai";
String outFileName = dataDir + "34992OStroke.jpg";
// Load input AI file
AiImage image = (AiImage)Image.load(sourceFileName);
// Initialize JpegOptions class instance
JpegOptions options = new JpegOptions();
options.setQuality(85);
// Save output JPEG image
image.save(outFileName, options);
String sourceFileName = dataDir + "34992OStroke.ai";
String outFileName = dataDir + "34992OStroke.pdf";
// Load input AI image file
AiImage image = (AiImage)Image.load(sourceFileName);
// Initilize PdfOptions object to specify different options
PdfOptions options = new PdfOptions();
// Save output PDF file
image.save(outFileName, options);
String dataDir = Utils.getDataDir(AIToPNG.class) + "AI/";
String sourceFileName = dataDir + "34992OStroke.ai";
String outFileName = dataDir + "34992OStroke.png";
// Load input AI file
AiImage image = (AiImage)Image.load(sourceFileName);
// Initilaize PngOptions instance
PngOptions options = new PngOptions();
options.setColorType(PngColorType.TruecolorWithAlpha);
// Save output PNG image
image.save(outFileName, options);
String dataDir = Utils.getDataDir(AIToPSD.class) + "AI/";
String sourceFileName = dataDir + "34992OStroke.ai";
String outFileName = dataDir + "34992OStroke.psd";
// Load input image
AiImage image = (AiImage)Image.load(sourceFileName);
// Initialize PsdOptions class object
PsdOptions options = new PsdOptions();
// Save output PSD file
image.save(outFileName, options);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment