Skip to content

Instantly share code, notes, and snippets.

@conholdate-gists
Created October 22, 2024 21:32
Show Gist options
  • Save conholdate-gists/f67b73529e63e96e8fb594cfbe76dbbe to your computer and use it in GitHub Desktop.
Save conholdate-gists/f67b73529e63e96e8fb594cfbe76dbbe to your computer and use it in GitHub Desktop.
Convert DXF to PNG JPG Image in Java
// Load the input file
String srcFile = dataDir + "conic.dxf";
com.aspose.cad.Image image = com.aspose.cad.Image.load(srcFile);
// Create an instance of CadRasterizationOptions
com.aspose.cad.imageoptions.CadRasterizationOptions rasterizationOptions = new com.aspose.cad.imageoptions.CadRasterizationOptions();
// Set page width & height
rasterizationOptions.setPageWidth(1200);
rasterizationOptions.setPageHeight(1200);
// Create an instance of PngOptions for the resultant image
com.aspose.cad.ImageOptionsBase options = new com.aspose.cad.imageoptions.PngOptions();
//Set rasterization options
options.setVectorRasterizationOptions(rasterizationOptions);
// Save resultant image
image.save(dataDir + "image.png", options);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment