Skip to content

Instantly share code, notes, and snippets.

@aspose-com-gists
Created February 27, 2025 11:01
Convert DWG to JPG in C#
using Aspose.CAD;
using Aspose.CAD.ImageOptions;
namespace AsposeThreeD
{
class DWGtoPDF
{
// Convert DWG to JPG/JPEG in C#
static void Main(string[] args)
{
string dir = "data/";
string sourceFilePath = dir + "file.dwg";
// Call the Load method of the Image class to load the source DWG file.
using (Image image = Image.Load(sourceFilePath))
{
// Create an object of CadRasterizationOptions and set its various properties such as PageWidth, PageHeight and AutomaticLayoutsScaling.
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions();
rasterizationOptions.PageWidth = 1600;
rasterizationOptions.PageHeight = 1600;
rasterizationOptions.AutomaticLayoutsScaling = true;
// Instantiate an instance of the JpegOptions class.
JpegOptions jpegOptions = new JpegOptions();
// Set the value of the VectorRasterizationOptions property.
jpegOptions.VectorRasterizationOptions = rasterizationOptions;
// Invoke the Save method to convert DWG to JPG.
image.Save(dir + "output.jpg", jpegOptions);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment