Hi Aspose,
I upgrade Aspose CAD from 20.9 to the lastest version 22.6. And then, I can not convert some dxf file to png. The exception threw is “Object reference not set to an instance of an object”
Bellow is my current code:
using(var image = Image.Load(inFile))
{
// Create an instance of CadRasterizationOptions
var rasterizationOptions = new CadRasterizationOptions
{
// Set page width & height
PageWidth = image.Width,
PageHeight = image.Height
};
//Get all layouts
Aspose.CAD.FileFormats.Cad.CadImage cadImage = (Aspose.CAD.FileFormats.Cad.CadImage)image;
Aspose.CAD.FileFormats.Cad.CadLayoutDictionary layouts = cadImage.Layouts;
foreach(Aspose.CAD.FileFormats.Cad.CadObjects.CadLayout layout in layouts.Values)
{
rasterizationOptions.Layouts = new string[] { layout.LayoutName };
// Create an instance of PngOptions for the resultant image
ImageOptionsBase option = new PngOptions();
// Set rasterization options
option.VectorRasterizationOptions = rasterizationOptions;
string outFilePath = Path.Combine(outFile, layout.LayoutName + "." + to);
image.Save(outFilePath, option);
}
}
The failed is cause by the layout in cad image has null value. Do you have any advice for me to handle this problem ? If this is a bug, please help me check and fix it.
Thanks!
Sample : sample.zip (57.8 KB)