DWG with External DWG References Fails to Convert to PDF

Hello,

I am evaluating Aspose.CAD .NET 18.3.0 (NuGet) and ran into issues with the very first DWG file I tried to convert to PDF.

I had to downgrade my Aspose.PDF .NET library to 18.1.0 from the latest version of 18.50 to get the past the exception on the Aspose.PDF version.

I have a collection of DWG files (1 main file and the other DWG files are as external references) from AutoCAD 2000. These are actually older sample files from AutoCAD themselves.

When converting to PDF or TIFF using any of the DWG files in the collection I get this exception:

Message: Exception thrown creating PDF document: Aspose.CAD.CadExceptions.ImageSaveException: Image saving failed. —> Aspose.CAD.CadExceptions.ImageSaveException: Image export failed. —> System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.

This is my convert to PDF code; the TIFF code is similar.

using (Aspose.CAD.Image CAD_image = Aspose.CAD.Image.Load(FILE_PATH))
{
	Aspose.CAD.ImageOptions.CadRasterizationOptions rasterizationOptions = null;
	try
	{
		// Create an instance of CadRasterizationOptions
		rasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions
		{

			// Set page width & height
			PageWidth = ((Aspose.CAD.Image)CAD_image).Width,
			PageHeight = ((Aspose.CAD.Image)CAD_image).Height,
			BackgroundColor = Aspose.CAD.Color.White,
			//DrawColor = Aspose.CAD.Color.Black,
			//DrawType = Aspose.CAD.FileFormats.Cad.CadDrawTypeMode.UseDrawColor,
			CenterDrawing = true,

			AutomaticLayoutsScaling = true,
			NoScaling = false,
	    };

		
		// Create an instance of TiffOptions
		Aspose.CAD.ImageOptions.TiffOptions tiff_Options = new Aspose.CAD.ImageOptions.TiffOptions(Aspose.CAD.FileFormats.Tiff.Enums.TiffExpectedFormat.Default)
		{
			// Set the VectorRasterizationOptions property
			VectorRasterizationOptions = rasterizationOptions
		};

		
		try
		{
			// Save resultant image
			CAD_image.Save(OUTPUT_DIR + OUTPUT_NAME, tiff_Options);
		}
		catch (Exception ex)
		{
			Assert.Fail("Exception thrown creating PDF document: {0}", ex.ToString());
		}
	}
	catch (Exception ex)
	{
		Assert.Fail("Exception thrown creating CadRasterizationOptions or PDFOptions for PDF : {0}", ex.ToString());
	}

}

Here is a zip containing the DWG sample files: 1st floor.zip (165.1 KB)

Thanks,

Sheri

@sheri_steeves,

I have tested the DWG file by using Aspose.CAD 18.3 and Aspose.PDF 18.5 in application with your sample code. I have not been able to reproduce the issue on my end and for your kind reference the sample project is also attached. Can you please try using this on your end and share a working sample project with us reproducing the issue if there is still an issue on your end.

CadTester.zip (32.2 KB)

@mudassir.fayyaz,

Thanks for the quick response.

I have the same issue running your CAD tester program with Aspose.CAD 18.3. and Aspose.PDF 18.5 as my own code.

When calling CAD_image.Save(FILE_PATH + “1st floor.tiff”, tiff_Options); it still throws the same exception:

(Exception thrown creating PDF document: Aspose.CAD.CadExceptions.ImageSaveException: Image saving failed. —> Aspose.CAD.CadExceptions.ImageSaveException: Image export failed.).

Two things:

  1. I am testing this in a Windows 10 VM using Visual Studio 2017
  2. I am also testing the evaluation version. I commented out the licensing code in your test code as I do not have a license. If you comment out the license in your code do you get the same error as I do?

Thanks,

Sheri

@sheri_steeves,

I have worked with sample code which shared with you above from my colleague and unable to observe any issue. I have also did not used any license file and tested this sample project on window 10 along with VS 2017. Can you please share your complete environment details with us so that we may further investigate to help you out.

@Adnan.Ahmad,

I am running:

  • 64-bit Windows 10 Enterprise 10.0.16299 on VMWare Workstation 14 Pro with the virtual machine set to have 8GB and 4 processers. 1 GB is set for graphics memory.
  • Visual Studio 2017 Professional 2017 Version 15.5.2

I get the same error in my project built against .NET 4.5 as in your CADTester program build against .NET 4.6.1.

In your test program, I restored the Aspose.CAD (18.3.0) and Aspose.PDF (18.5.0) library from NuGet and ran the test. The exception occurred on the CAD_image.Save() method when I tried to create the TIFF.

I added options to create a PDF too and get the same exception.

Sheri

@sheri_steeves,

Please check this snapshot that exhibit the successful operation of application on my end without any issue. I have even set the .NET Framework to 4.5 in project settings and there is no issue. As requested earlier, please share the working sample project with all project settings on your end that is reproducing the issue on your end. Please share the requested information so that we may try reproducing the issue on our end.

@mudassir.fayyaz,

Please find my sample project attached, although I was getting the exact same exception when running the CADTester sample project you sent yesterday.

PEERNETCADTester.zip (160.9 KB)

One important thing to note: If “1st plan.dwg” is the only file in the C:\Cad Data\ folder, then the conversion will succeed!

If you have all of the files from the zip I sent yesterday (see first post), THEN the conversion will fail. If you’ve been testing with just “1st plan.dwg” you will not see the exception.

You will want all of the following files in the C:\Cad Data\ folder to see the exception:

  • 1st plan.dwg
  • 1st floor plan.dwg
  • 1st floor lighting.dwg
  • 1st floor electrical.dwg
  • 1st floor architectural.dwg

Thanks,
Sheri

@sheri_steeves,

I have observed your comments. So far, you have only shared following file with us which worked fine.

For your following comments:

Please share the requested files with us so that we may perform testing on our end.

@mudassir.fayyaz

Sorry about that, I thought I had zipped them all up together.

Try this one: 1st floor (ALL).zip (662.6 KB)

@sheri_steeves,

I have worked with new files shared by you and this time I am able to reproduce the issue on my end. An issue with ID CADNET-619 has been added 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.

The issues you have found earlier (filed as ) have been fixed in this update.