Skip to content

Instantly share code, notes, and snippets.

@aspose-com-kb
Last active January 6, 2024 13:16
Show Gist options
  • Save aspose-com-kb/4e56eaf861560f59f9cadc68a534725a to your computer and use it in GitHub Desktop.
Save aspose-com-kb/4e56eaf861560f59f9cadc68a534725a to your computer and use it in GitHub Desktop.
Convert DWG to TIFF in C#. For more details: https://kb.aspose.com/cad/net/convert-dwg-to-tiff-in-csharp/
using System;
using Aspose.CAD;
using Aspose.CAD.FileFormats.Tiff.Enums;
using Aspose.CAD.ImageOptions;
namespace TestCAD
{
public class DwgToTiff
{
public static void ConvertDwgToTiff()
{
String filePath = @"/Users/KnowledgeBase/TestData/";
// Initialize a license to convert DWG to TIFF
License licenseTiff = new License();
licenseTiff.SetLicense(filePath + "Total.Product.lic");
using (Image cadImage = Image.Load(filePath + "sample.dwg"))
{
//Instantiate CadRasterizationOptions class object
CadRasterizationOptions dwgRasOpts = new CadRasterizationOptions();
//Set the output tiff page size
dwgRasOpts.PageHeight = 450;
dwgRasOpts.PageWidth = 450;
// Create an instance of TiffOptions
TiffOptions tiffOpts = new TiffOptions(TiffExpectedFormat.Default);
// Setting the VectorRasterizationOptions property
tiffOpts.VectorRasterizationOptions = dwgRasOpts;
//Export CAD to TIFF Image
cadImage.Save(filePath + "resultout.tiff", tiffOpts);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment