Skip to content

Instantly share code, notes, and snippets.

@aspose-com-gists
Created February 1, 2022 08:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aspose-com-gists/3c3b7cc7aac450ec575551b623dd4172 to your computer and use it in GitHub Desktop.
Save aspose-com-gists/3c3b7cc7aac450ec575551b623dd4172 to your computer and use it in GitHub Desktop.
Convert DWF to PNG or JPG JPEG Image Programmatically in Java
String inputFile = "blocks_and_tables.dwf";
// Load the input DWF file
Image image = Image.load(inputFile);
// Initialize JpegOptions class object
JpegOptions jpgOptions = new JpegOptions();
CadRasterizationOptions dwfRasterizationOptions = new CadRasterizationOptions();
jpgOptions.setVectorRasterizationOptions(dwfRasterizationOptions);
dwfRasterizationOptions.setPageHeight(500);
dwfRasterizationOptions.setPageWidth(500);
// Export DWF to JPG image
String outPath = "blocks_and_tables.jpg";
image.save(outPath, jpgOptions);
String inputFile = "blocks_and_tables.dwf";
// Load the input DWF file
Image image = Image.load(inputFile);
// Initialize PngOptions class object
PngOptions pngOptions = new PngOptions();
CadRasterizationOptions dwfRasterizationOptions = new CadRasterizationOptions();
pngOptions.setVectorRasterizationOptions(dwfRasterizationOptions);
dwfRasterizationOptions.setPageHeight(500);
dwfRasterizationOptions.setPageWidth(500);
// Export DWF to PNG image
String outPath = "blocks_and_tables.png";
image.save(outPath, pngOptions);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment