Exception in loading a CadImage from a file

I’m trying to convert a DXF to PDF with AsposeCad for .NET, ver 21.4.0.
I get this exception when converting : System.NullReferenceException: ‘Object reference not set to an instance of an object.’ on the using statement of the following code

				using (CadImage image = (CadImage)Image.Load(sourceFilePath))
				CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions();
				rasterizationOptions.UnitType = UnitType.Millimeter;					

				rasterizationOptions.PageWidth = 420;
				rasterizationOptions.PageHeight = 297;

				rasterizationOptions.Layouts = new string[] {"Layout1" };

				rasterizationOptions.DrawType = CadDrawTypeMode.UseObjectColor;

				PdfOptions pdfOptions = new PdfOptions();

				pdfOptions.VectorRasterizationOptions = rasterizationOptions;

				string fileName = Path.GetFileName(sourceFilePath);
				string outputDir = Path.GetDirectoryName(sourceFilePath);
				string outputFileName = fileName.Replace(".dxf", ".pdf");
				string savePDFfilePath = outputDir + @"\" + outputFileName;
				image.Save(savePDFfilePath, pdfOptions);


Can you please share the source CAD file throwing error on your end?

This is a file throwing error

test_dim.zip (2.5 KB)

This is the StackTrace:

at Aspose.CAD.FileFormats.Cad.CadImage.SetSize()


I have created an issue with ID CADNET-8132 in our issue tracking system to further investigate and resolve the issue. This thread has been linked with the issue so that you may be notified once the issue will be fixed.

It’s weird that the Image.CanLoad method returns true.


The issue has been added for investigation and we request for your patience. We will share the good news with you as soon as it will be fixed.