PNG
JPG
PDF
XML
AI
PNG
Convert AI to PNG via Java
Native Java Library to Read, Write & Export AI to PNG without needing Adobe.
How to Convert AI to PNG Using Java
In order to render AI to PNG, we’ll use Aspose.PSD for Java API which is a feature-rich, powerful and easy to use conversion API for Java platform. You can download its latest version directly from Maven and install it within your Maven-based project by adding the following configurations to the pom.xml.
Repository
<repository>
<id>AsposeJavaAPI</id>
<name>Aspose Java API</name>
<url>https://repository.aspose.com/repo/</url>
</repository>
Dependency
<dependency>
<groupId>com.aspose</groupId>
<artifactId>aspose-psd</artifactId>
<version>version of aspose-psd API</version>
<classifier>jdk17</classifier>
</dependency>
Steps to Convert AI to PNG via Java
Aspose.PSD API makes it easy for the developers to convert AI file to PNG in just a few lines of code.
- Load input AI image
- Initialize PngOptions class object
- Specify image properties
- Save output PNG image
System Requirements
Aspose.PSD for Java supports on all major platforms and Operating Systems. Please make sure that you have the following prerequisites.
- Microsoft Windows or a compatible OS with Java Runtime Environment for JSP/JSF Application and Desktop Applications.
- Get latest version of Aspose.PSD for Java directly from Aspose Maven Repository .
Convert AI to PNG - Java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Convert AI file of version 8 to PNG file format. It just loads an existing AI file then saves in PNG image file format. | |
String inAiFilePath = "form_8.ai"; | |
String outPngFilePath = "form_8_export.png"; | |
// Load an AI file of 8 version | |
AiImage aiImage = (AiImage)Image.load(inAiFilePath); | |
try{ | |
// Save the loaded AI file as a PNG file with a white background | |
PngOptions pngOptions = new PngOptions(); | |
pngOptions.setColorType(PngColorType.TruecolorWithAlpha); | |
aiImage.save(outPngFilePath, pngOptions); | |
}finally{ | |
aiImage.dispose(); | |
} |