How to export CAD files to JPEG with a specified DPI?
- Add a new button. Name it 
ExportBMP. Then create theExportBMP_Clickfunction to export a CAD file to BMP by click. 
private void ExportBMP_Click(object sender, EventArgs e){
- Use the 
ShowDialogmethod to load a CAD file from the dialog window. Create a new instance of theCADImageclass. 
  if ((openFileDialog1.ShowDialog() != DialogResult.OK)) return;
  CADImage vDrawing = CADImage.CreateImageByExtension(openFileDialog1.FileName);
  vDrawing.LoadFromFile(openFileDialog1.FileName);
We recommend creating a new drawing object using CreateImageByExtension in case of importing from an existing file or stream.
- Declare the local variables 
vHeightandvWidthofDouble. Don't forget to check thevHeightvalue for exceeding the permissible limits. Finally, create an instance of theBitmapclass and assign valuesvWidthandvHeightto theWidthandHeightproperties. 
  Double vHeight = 1;
  Double vWidth = 1000;
  if (vDrawing.AbsWidth != 0)
    {
      vHeight = vWidth * (vDrawing.AbsHeight / vDrawing.AbsWidth);
      if (vHeight > 4096)
        {
          vHeight = 4096;
        }
      vHeight = Math.Round(vHeight);
    }
  Bitmap vBitmap = new Bitmap((int)(vWidth), (int)(vHeight));
We recommend using such kind of the Height and Width properties checks to avoid exceptions.
- Set 
DPIwith theSetResolutionmethod. 
vBitmap.SetResolution(300, 300);
- Create an instance of the 
Graphicsclass. 
Graphics vGr = Graphics.FromImage(vBitmap);
- Render the CAD file to 
vGrwith theDrawmethod. 
RectangleF vRect = new RectangleF(0, 0, (float)1000, (float)(vBitmap.Width * vDrawing.AbsHeight / vDrawing.AbsWidth));
vDrawing.Draw(vGr, vRect);
- Finally, export the CAD file to JPEG with the 
Savemethod. 
vBitmap.Save(openFileDialog1.FileName + ".jpeg", System.Drawing.Imaging.ImageFormat.Jpeg);
You have created the function to export CAD files to JPEG with a specified DPI.
The full code listing.
...
using CADImport;
namespace WindowsFormsApp1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }  
        private void ExportToJpeg_Click(object sender, EventArgs e)
        {
          if ((openFileDialog1.ShowDialog() != DialogResult.OK)) return;
          CADImage vDrawing = CADImage.CreateImageByExtension(openFileDialog1.FileName);
          vDrawing.LoadFromFile(openFileDialog1.FileName);
          Double vHeight = 1;
          Double vWidth = 1000;
          if (vDrawing.AbsWidth != 0)
          {
            vHeight = vWidth * (vDrawing.AbsHeight / vDrawing.AbsWidth);
            if (vHeight > 4096)
            {
              vHeight = 4096;
            }
            vHeight = Math.Round(vHeight);
          }
          Bitmap vBitmap = new Bitmap((int)(vWidth), (int)(vHeight));
          vBitmap.SetResolution(300, 300);
          Graphics vGr = Graphics.FromImage(vBitmap);
          RectangleF vRect = new RectangleF(0, 0, (float)(vWidth), (float)(vHeight));
          vDrawing.Draw(vGr, vRect);
          vBitmap.Save(openFileDialog1.FileName + ".jpeg", System.Drawing.Imaging.ImageFormat.Jpeg);
        }
    }
}