Load, render, view, convert CAD document using C#

Blog category: Imaging.NET

August 04, 2026

CAD document is a digital file created in a computer-aided design system. A CAD document contains design data: 2D drawings, 3D models, geometry, dimensions, materials, annotations and other information necessary for the design, production, construction, or operation of a facility.

The most popular file formats for storing CAD documents are DWG and DXF.

The DWG file format (from the word "drawing") has been licensed by Autodesk as the primary format for AutoCAD since 1982.

DXF (Drawing Exchange Format) is an open file format created by Autodesk for exchanging graphical information between different computer-aided design systems. It allows to transfer precise vector drawings that can be opened and edited in various programs.

VintaSoft Imaging .NET SDK allows to load a CAD document from a DWG or DXF file. The loaded CAD document can be rendered, viewed, and converted.

In this article, we will cover the most common situations that arise when loading, rendering, viewing and converting CAD documents. All code examples below use the VintaSoft Imaging .NET SDK.


Rendering CAD document pages

Each page of a CAD document can be rendered, meaning it can be converted into an image.

Here's C# code that demonstrates how to render all pages of a CAD document and save them as PNG files:
/// <summary>
/// Converts pages of CAD document to the PNG files.
/// </summary>
public static void ConvertCadToPng(string cadFileName)
{
    // specify that VintaSoft Imaging .NET SDK should use GDI+ for drawing of 2D graphics
    Vintasoft.Imaging.Drawing.Gdi.GdiGraphicsFactory.SetAsDefault();
    // specify that VintaSoft Imaging .NET SDK should use SkiaSharp for drawing of 2D graphics
    //Vintasoft.Imaging.Drawing.SkiaSharp.SkiaSharpDrawingFactory.SetAsDefault();

    // create image collection
    using (Vintasoft.Imaging.ImageCollection images = new Vintasoft.Imaging.ImageCollection())
    {
        // add CAD document to the image collection
        images.Add(cadFileName);

        // create PNG encoder
        using (Vintasoft.Imaging.Codecs.Encoders.PngEncoder pngEncoder =
            new Vintasoft.Imaging.Codecs.Encoders.PngEncoder())
        {
            // for each page in CAD document
            for (int i = 0; i < images.Count; i++)
            {
                // save rendered image to a PNG file
                images[i].Save(string.Format("page{0}.png", i), pngEncoder);
            }
        }

        // dispose images
        images.ClearAndDisposeItems();
    }
}


Viewing a CAD document in a WinForms application

The WinForms UI-control ImageViewer allows to view a CAD document.
Here is C# code that demonstrates how to view a CAD document in WinForms UI-control ImageViewer in a WinForms application:
...
// open CAD file in WinForms image viewer
imageViewer1.Images.Add("cube.dxf");
...


Viewing a CAD document in a WPF application

The WPF UI-control WpfImageViewer allows to view a CAD document.
Here is C# code that demonstrates how to view a CAD document in WPF UI-control WpfImageViewer in a WPF application:
...
// open CAD file in WPF image viewer
wpfImageViewer1.Images.Add("cube.dxf");
...


Viewing a CAD Document in a Web Application

The JavaScript UI-control WebImageViewerJS allows to view a CAD document.
Here is JavaScript code that demonstrates how to view a CAD document in JavaScript UI-control WebImageViewerJS in a web application:
...
var imageViewer1 = new Vintasoft.Imaging.UI.WebImageViewerJS("WebImageViewer1");
// open CAD file in web image viewer
imageViewer1.get_Images().openFile("cube.dxf");
...


The JavaScript UI-control WebDocumentViewerJS also allows to view a CAD document.
Here is JavaScript code that demonstrates how to view a CAD document in JavaScript UI-control WebDocumentViewerJS in a web application:
...
// create the document viewer
var docViewer1 = new Vintasoft.Imaging.DocumentViewer.WebDocumentViewerJS(docViewerSettings);
...
// open CAD file in web document viewer
docViewer1.openFile("cube.dxf");
...


Printing a CAD document

If you need to print a CAD document in a WPF application, please read the article 'Printing Images in WPF'.

If you need to print a CAD document in a WinForms or console application, please read the article 'Printing Images Using the System.Drawing Library'.


Converting a CAD file to a PDF file

The process of converting a CAD file to a PDF file consists of the following steps:

Here is C# code that demonstrates how to convert a CAD file to a PDF file:
/// <summary>
/// Converts CAD document to a PDF document using ImageCollection and PdfEncoder classes.
/// </summary>
public static void ConvertCadToPdf(string cadFileName, string pdfFileName)
{
    // specify that VintaSoft Imaging .NET SDK should use GDI+ for drawing of 2D graphics
    Vintasoft.Imaging.Drawing.Gdi.GdiGraphicsFactory.SetAsDefault();
    // specify that VintaSoft Imaging .NET SDK should use SkiaSharp for drawing of 2D graphics
    //Vintasoft.Imaging.Drawing.SkiaSharp.SkiaSharpDrawingFactory.SetAsDefault();

    // create image collection
    using (Vintasoft.Imaging.ImageCollection imageCollection = new Vintasoft.Imaging.ImageCollection())
    {
        // add CAD document to the image collection
        imageCollection.Add(cadFileName);

        // create PDF encoder
        using (Vintasoft.Imaging.Codecs.Encoders.PdfEncoder pdfEncoder = 
            new Vintasoft.Imaging.Codecs.Encoders.PdfEncoder(true))
        {
            // set the compression for image-resources in PDF document
            pdfEncoder.Settings.Compression = Vintasoft.Imaging.Codecs.Encoders.PdfImageCompression.Jpeg;

            // save images (CAD document) to a PDF document using PDF encoder
            imageCollection.SaveSync(pdfFileName, pdfEncoder);
        }

        // dispose images
        imageCollection.ClearAndDisposeItems();
    }
}


Converting a CAD file to a multi-page TIFF file

The process of converting a CAD file to a multi-page TIFF file consists of the following steps:

Here's C# code that demonstrates how to convert a CAD file to a multi-page TIFF file:
/// <summary>
/// Converts CAD document to TIFF file using ImageCollection and TiffEncoder classes.
/// CAD document is rendered with specified resolution.
/// </summary>
public static void ConvertCadToTiff(string cadFileName, string tiffFileName, float dpi)
{
    // specify that VintaSoft Imaging .NET SDK should use GDI+ for drawing of 2D graphics
    Vintasoft.Imaging.Drawing.Gdi.GdiGraphicsFactory.SetAsDefault();
    // specify that VintaSoft Imaging .NET SDK should use SkiaSharp for drawing of 2D graphics
    //Vintasoft.Imaging.Drawing.SkiaSharp.SkiaSharpDrawingFactory.SetAsDefault();

    // create image collection
    using (Vintasoft.Imaging.ImageCollection imageCollection = new Vintasoft.Imaging.ImageCollection())
    {
        // add CAD document to the image collection
        imageCollection.Add(cadFileName);

        // set the rendering settings for CAD document
        imageCollection.SetRenderingSettings(new Vintasoft.Imaging.Codecs.Decoders.RenderingSettings(dpi, dpi));

        // create TiffEncoder
        using (Vintasoft.Imaging.Codecs.Encoders.TiffEncoder tiffEncoder = 
            new Vintasoft.Imaging.Codecs.Encoders.TiffEncoder(true))
        {
            // set TIFF compression to Zip
            tiffEncoder.Settings.Compression = 
                Vintasoft.Imaging.Codecs.ImageFiles.Tiff.TiffCompression.Zip;

            // save images (CAD document) to a multipage TIFF file using TiffEncoder
            imageCollection.SaveSync(tiffFileName, tiffEncoder);
        }

        // dispose images
        imageCollection.ClearAndDisposeItems();
    }
}


Converting a CAD file to PNG files

The process of converting a CAD file to PNG files consists of the following steps:

Here's C# code that demonstrates how to convert a CAD file to PNG files:
/// <summary>
/// Converts pages of CAD document to the PNG files.
/// </summary>
public static void ConvertCadToPng(string cadFileName)
{
    // specify that VintaSoft Imaging .NET SDK should use GDI+ for drawing of 2D graphics
    Vintasoft.Imaging.Drawing.Gdi.GdiGraphicsFactory.SetAsDefault();
    // specify that VintaSoft Imaging .NET SDK should use SkiaSharp for drawing of 2D graphics
    //Vintasoft.Imaging.Drawing.SkiaSharp.SkiaSharpDrawingFactory.SetAsDefault();

    // create image collection
    using (Vintasoft.Imaging.ImageCollection images = new Vintasoft.Imaging.ImageCollection())
    {
        // add CAD document to the image collection
        images.Add(cadFileName);

        // create PNG encoder
        using (Vintasoft.Imaging.Codecs.Encoders.PngEncoder pngEncoder =
            new Vintasoft.Imaging.Codecs.Encoders.PngEncoder())
        {
            // for each page in CAD document
            for (int i = 0; i < images.Count; i++)
            {
                // save rendered image to a PNG file
                images[i].Save(string.Format("page{0}.png", i), pngEncoder);
            }
        }

        // dispose images
        images.ClearAndDisposeItems();
    }
}


Converting a CAD file to SVG files

The process of converting a CAD file to SVG files consists of the following steps:

Here is C# code that demonstrates how to convert a CAD file to SVG files:
/// <summary>
/// Converts CAD document to the SVG files using ImageCollection and SvgEncoder classes.
/// </summary>
public static void ConvertCadToSvg(string cadFileName)
{
    // specify that VintaSoft Imaging .NET SDK should use GDI+ for drawing of 2D graphics
    Vintasoft.Imaging.Drawing.Gdi.GdiGraphicsFactory.SetAsDefault();
    // specify that VintaSoft Imaging .NET SDK should use SkiaSharp for drawing of 2D graphics
    //Vintasoft.Imaging.Drawing.SkiaSharp.SkiaSharpDrawingFactory.SetAsDefault();

    // create image collection
    using (Vintasoft.Imaging.ImageCollection images = new Vintasoft.Imaging.ImageCollection())
    {
        // add CAD document to the image collection
        images.Add(cadFileName);

        // create SVG encoder
        using (Vintasoft.Imaging.Codecs.Encoders.SvgEncoder svgEncoder =
            new Vintasoft.Imaging.Codecs.Encoders.SvgEncoder())
        {
            // specify that SVG encoder should compress embedded image using PNG compression
            svgEncoder.Settings.EmbeddedImageEncoder = new Vintasoft.Imaging.Codecs.Encoders.PngEncoder();

            // for each page in CAD document
            for (int i = 0; i < images.Count; i++)
            {
                // save page to SVG file
                images[i].Save(string.Format("page{0}.svg", i), svgEncoder);
            }
        }

        // dispose images
        images.ClearAndDisposeItems();
    }
}