Convert DWF to PNG or JPG Image in Java

DWF to JPG PNG Java

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

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:

  1. Firstly, load source DWF file with the Image class constructor.
  2. Initialize CadRasterizationOptions class object.
  3. Create an instance of JpegOptions type.
  4. 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:

  1. Load the input DWF file using the Image class.
  2. Initialize an object of CadRasterizationOptions class.
  3. Create PngOptions class object.
  4. 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.

See Also

Convert CFF to PDF Programmatically in Java