Free Support Forum - aspose.com

DXF to SVG "KeyNotFoundException"

We are having trouble with some DXF files not wanting to convert to SVG (or any other type).

We get the following error:

ImageSaveException : Image export failed.
KeyNotFoundException : La clé donnée était absente du dictionnaire.

I have included one of the DXF files giving us this problem, these are files provided to us by our clients, they open up without any problems using software like QCAD.

test_dxf.zip (9.6 KB)

@David_Gomez,

Can you please share source code along with complete environment details so that we may further investigate to help you out.

@Adnan.Ahmad

 var sourceFilePath = @"D:\test.dxf";
    using (Aspose.CAD.FileFormats.Cad.CadImage image = (Aspose.CAD.FileFormats.Cad.CadImage)Aspose.CAD.Image.Load(sourceFilePath))
    {
    	Aspose.CAD.ImageOptions.CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions()
    	{
    		BackgroundColor = Aspose.CAD.Color.White,
    		PageHeight = 3200,
    		PageWidth = 3200,
    		UnitType = UnitType.Meter,
    		Layouts = new string[] { "Model" },
    		AutomaticLayoutsScaling = true,
    		NoScaling = false
    	};
    	
    	Aspose.CAD.ImageOptions.SvgOptions svgOptions = new Aspose.CAD.ImageOptions.SvgOptions()
    	{
    		VectorRasterizationOptions = rasterizationOptions,
    		};

    	//Export the DXF to SVG
    	image.Save(@"D:\test.svg", svgOptions);
    }

Testing in Visual Studio 2017 on a Windows 10 Pro (french) computer using the latest Aspose.CAD nuget

@David_Gomez,

I have worked with source code and sample file shared by you and unable to observe the issue. I have also shared my generated result with you for your kind reference. Can you please try to use latest version 19.9 on your end and share feedback with us. testdxf.zip (80.9 KB)

@Adnan.Ahmad

Thanks for the quick response, we have figured out what the problem was, there was a linetype that was used by an object but it wasn’t part of the linetype dictionnary. This is what was giving us the KeyNotFound error.

Thanks for your help

@David_Gomez,

Its good to know that you problem has been resolved. Please share feedback with us if there is still an issue.