Skip to content

Instantly share code, notes, and snippets.

@aspose-com-gists
Last active August 8, 2023 09:49
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aspose-com-gists/b9ecee55e642a56085a75d2119281959 to your computer and use it in GitHub Desktop.
Save aspose-com-gists/b9ecee55e642a56085a75d2119281959 to your computer and use it in GitHub Desktop.
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