Free Support Forum -

Convert .dwg file in raster image using Java


How to convert .dwg file in raster image (.bmp or .png)?
I use GroupDocs.Viewer trial for Java

Hi Muzychuk,

Thanks for taking interest in GroupDocs.Viewer for Java.
We would like to know, which version of the API (GroupDocs.Viewer for Java) you are using in your project or evaluating ?

Kind Regards

The issues you have found earlier (filed as VIEWERJAVA-1220) have been fixed in this update.

This message was posted using Notification2Forum from Downloads module by groupdocs.notifier.

I use GroupDocs.Viewer for Java version 3.2.2

Kind Regards,
Boris Muzychuk

Hi Boris,

Thanks for providing the required information.
We are pleased to inform you that you can render .dwg file into .png image(s). You may find following resources helpful:
Please go through the above mentioned resources and share your experience.
We are always here to help you out.

Kind Regards

Hi Atir,

Thanks for the answer.
I went through the above mentioned resources. I have tried render .dwg file into .png and I have got incorrect .png file. I used example from GitHub:
<pre style=“background-color: rgb(255, 255, 255); font-family: “Courier New”;”>ViewGenerator.renderDocumentAsImage(“Bottom_plate.dwg”);<pre style=“background-color: rgb(255, 255, 255); font-family: “Courier New”;”>
<pre style=“background-color: rgb(255, 255, 255); font-family: “Courier New”;”><pre style=“font-family: “Courier New”;”>public static void renderDocumentAsImage(String fileName) {
// ExStart:GetDocumentImageRepresentation
try {
// Setup GroupDocs.Viewer config
ViewerConfig config = Utilities.getConfiguration();
// Create image handler
ViewerImageHandler imageHandler = new ViewerImageHandler(config);
String guid = fileName;

ImageOptions imageOptions = new ImageOptions();
// Get pages
List pages = imageHandler.getPages(guid, imageOptions);

// Save pages
for (PageImage page : pages) {
Utilities.saveAsImage(page.getPageNumber() + “_” + fileName, “png”, page.getStream());
} catch (Exception exp) {
System.out.println("Exception: " + exp.getMessage());
// ExEnd:GetDocumentImageRepresentation
}<pre style=“font-family: “Courier New”;”>I attached zip-archive with .dwg and .png files.

Hi Boris,

Thanks for sharing the sample file.
We have successfully reproduced this issue at our end. Hence, we have logged it in our internal issue tracking system with ID VIEWERJAVA-1220. As we get any update from the concerned team we will notify you.

Best Wishes