Convert DWG to EMF or WMF in Java

DWG to EMF WMF Java

DWG files contain vector image data and metadata written with binary coding and are widely used for designing purposes. In particular scenarios, you may want to convert DWG to image format. Considering such requirements, this article covers how to convert a DWG file to an EMF or WMF image programmatically in Java.

DWG to EMF or WMF Image Converter – Java API Installation

Aspose.CAD for Java API is a standalone solution to create, edit, or manipulate CAD drawings without needing to configure any CAD application. You can easily configure the API by downloading its JAR file from the Downloads section or with the following Maven configurations:

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 DWG to EMF Image Programmatically in Java

You can convert a DWG file to an EMF image by following the steps below:

  1. Load the input DWG file using the Image class constructor.
  2. Instantiate an object of CadRasterizationOptions class.
  3. Set different properties for output image.
  4. Save the output EMF image.

The following code sample explains how to convert a DWG file to an EMF image programmatically in Java:

Convert DWG to WMF Image Programmatically in Java

You can convert a DWG file to a WMF image with the steps below:

  1. Firstly, load the input DWG file with the Image class.
  2. Initialize an instance of CadRasterizationOptions class.
  3. Initialize WmfOptions class object.
  4. Save the output WMF image.

The following code sample elaborates how to convert a DWG file to a WMF image programmatically in Java:

Get Free Temporary License

You can evaluate the API features in their full capacity, without any limitations by requesting a free temporary license.

Conclusion

In this article, you have inspected how to convert a DWG file to an EMF or WMF image file programmatically in Java. Furthermore, please take a look at the documentation section to take a look at other features of the API. Please feel free to contact us at the forum in case of any inquiries.

See Also

Convert DWG to DXF in Java