DWF files contain 2D or 3D drawings in compressed format. In certain situations, you might need to convert DWF to an image. Considering that perspective, the article covers how to convert a DWF file to a JPG or PNG image programmatically using Java.
- DWF to JPG or PNG Image Converter – Java API Installation
- Convert DWF to JPG Image Programmatically in Java
- Convert DWF to PNG Image Programmatically in Java
DWF to JPG or PNG Image Converter – Java API Installation
Aspose.CAD for Java API can be used to create, edit, or manipulate CAD files without even needing to install CAD applications. Simply install the API by downloading its JAR file from the Downloads section or using the Maven configurations below:
Repository:
<repositories>
<repository>
<id>AsposeJavaAPI</id>
<name>Aspose Java API</name>
<url>http://repository.aspose.com/repo/</url>
</repository>
</repositories>
Dependency:
<dependencies>
<dependency>
<groupId>com.aspose</groupId>
<artifactId>aspose-cad</artifactId>
<version>21.11</version>
</dependency>
</dependencies>
Convert DWF to JPG Image Programmatically in Java
You can convert a DWF file to a JPG image with the following steps:
- Firstly, load source DWF file with the Image class constructor.
- Initialize CadRasterizationOptions class object.
- Create an instance of JpegOptions type.
- Save the output JPG image using VectorRasterizationOptions.
The following code snippet elaborates how to convert a DWF file to a JPG image in Java:
Convert DWF to PNG Image Programmatically in Java
You can convert a DWF file to a PNG image with the following steps:
- Load the input DWF file using the Image class.
- Initialize an object of CadRasterizationOptions class.
- Create PngOptions class object.
- Finally, save the output PNG image with VectorRasterizationOptions.
The code snippet below shows how to convert a DWF to a PNG image in Java:
Get Free Temporary License
You can test the API in its full capacity by requesting a free temporary license.
Conclusion
In this article, you have learned how to convert a DWF file to an image as a JPG or PNG file programmatically in Java. You may take a look at the documentation section to explore other features supported by the API. Furthermore, feel free to reach out to us at the forum in case of any concerns.