Set drawing background color

When converting CAD drawings with GroupDocs.Viewer there is no background color set by default but we proved an option that enables you to set any background color.

Setting background color when converting CAD Drawings

Let’s check how does output looks when converting sample CAD drawing with GroupDocs.Viewer for Java.

And as you can see the background color of the output image below is white.

Now, lets set background color and convert CAD drawing one more time.

To set background color you need to specify the setBackgroundColor() property value in the CadOptions class.

The following code snippet shows how to set background color.

    try (Viewer viewer = new Viewer("input.dwg")) {
        PngViewOptions options = new PngViewOptions(pageFilePathFormat);
        options.getCadOptions().setBackgroundColor(Color.BLUE);
        viewer.view(options);
    }

And here is output image with blue background color: