ImageGear .NET v24.14 - Updated September 15, 2020
CAD to Image
User Guide > How to Work with... > CAD > How To ... > Convert ... > CAD to Image

The CADViewer demo demonstrates this functionality. See Samples.

The following CADRaster sample illustrates how you can create a raster page from a CAD page:

C#
Copy Code
using System.IO;
using ImageGear.Formats;
using ImageGear.Formats.CAD;

public static void CadToRaster(string path)
{
     ImGearCADPage page = null;

     // Load file.
     using (FileStream fileStream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read))
     {
         page = ImGearFileFormats.LoadPage(fileStream, 0);
     }

     // Get an ImGearRasterPage from the loaded ImGearCADPage
     ImGearRasterPage raster = page.Rasterize();
}

 If you simply wish to save your CAD file as an image the following sample shows how this can be done:

C#
Copy Code
using System.IO;
using ImageGear.Formats;
using ImageGear.Formats.CAD;

public static void CadToImage(string inPath, string outPath)
{
    ImGearCADPage page = null;

    // Load file.
    using (FileStream fileStream = new FileStream(inPath, FileMode.Open, FileAccess.Read, FileShare.Read))
    {
        page = ImGearFileFormats.LoadPage(fileStream, 0);
    }

    // Save a CAD file to a PNG image
    ImGearSavingFormats formatOut = ImGearSavingFormats.PNG;
    using (FileStream fileStream = new FileStream(outPath, FileMode.Create, FileAccess.Write, FileShare.Read))
    {
        ImGearFileFormats.SavePage(page, fileStream, formatOut);
    }
}
Any conversions made to the CADPage’s camera will reflect in the saved image.