How to set background color when converting CAD Drawings


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.

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 BackgroundColor property value in the CadOptions class. 

The following code snippet shows how to set background color.

using (Viewer viewer = new Viewer("input.dwg"))
    PngViewOptions options = new PngViewOptions(pageFilePathFormat);
    options.CadOptions.BackgroundColor = System.Drawing.Color.Blue;

And here is output image with blue background color:

More resources

GitHub Examples

You may easily run the code above and see the feature in action in our GitHub examples:

Free Online App

Along with full-featured .NET library we provide simple but powerful free Apps. You are welcome to view Word, PDF, Excel, PowerPoint documents with free to use online GroupDocs Viewer App.