Free Support Forum - aspose.com

DWG to PDF: Low quality conversion (C# .NET)

While using the function below with standard rasterization options, the results for the attached dwg (an example, not the only one it occurs) the result come out very different from the expected (also attached):

try
{
	FileInfo fileInfo = new FileInfo(pVaultFileInfo.FSPath);
	License license = new License();
	license.SetLicense(LicStream);
	using (Image image = Image.Load(pVaultFileInfo.FSPath))
	{
		var rasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions()
		{
			PageSize = image.Size,
			BackgroundColor = Color.White
		};

		try
		{
			image.Save(
			Path.Combine(pdfsDir, pVaultFileInfo.FileName + ".pdf"),
			new Aspose.CAD.ImageOptions.PdfOptions()
			{
				VectorRasterizationOptions = rasterizationOptions
			});
		}
		catch (Exception e)
		{
			LicStream.Close();

			Console.WriteLine("Exception: " + e.ToString());

			if (TrueviewWorkaround(pVaultFileInfo))
				return true;

			return false;
		}
		finally
		{
			LicStream.Close();
		}
	}
}
catch (ImageLoadException e)
{
	LicStream.Close();

	this.AppendLog(pdfsDir, logFileName, e.ToString(), true);

	if (TrueviewWorkaround(pVaultFileInfo))
		return true;

	return false;
}
catch (Exception e)
{
	LicStream.Close();

	Console.WriteLine("Exception: " + e.ToString());
	this.AppendLog(pdfsDir, logFileName, e.ToString(), true);

	return false;
}

problematic files.zip (764.1 KB)

I am using Aspose.CAD for .NET v. 19.7.0

@ralemos,

I have worked with file shared by you and have been able to observe issue. A ticket with ID CADNET-953 has been created in our issue tracking system to further investigate and resolve the issue. This thread has been linked with issue so that you may be automatically notified once issue will be fixed.

Any updates on this? I already tested with version 19.9 and the issue still occurs…

@ralemos,

I have verified the issue status from our issue tracking system and like to share that the issue is still unresolved. We request for your patience till the time the issue gets resolved. We will share notification with you as soon as the issue will be fixed.

@ralemos,

We have investigated the requirements on our end. Actually, the image size of the attached sample is too small. In order to have a correct rendering result, one of the rasterization options should be specified:
1: specify “large” unittype (centimeter, meter, etc)

For example,

 using (CadImage cadImage = (CadImage)Image.Load(fileName))
    {
    CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions();
    rasterizationOptions.BackgroundColor = Color.White;
    rasterizationOptions.UnitType = UnitType.Centimenter;

    PdfOptions pdfOptions = new PdfOptions { VectorRasterizationOptions = rasterizationOptions };

    cadImage.Save(outPath, pdfOptions);
    }

2: manually specify rasterization page size
For example:

    using (CadImage cadImage = (CadImage)Image.Load(fileName))
    {
    CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions();
    rasterizationOptions.BackgroundColor = Color.White;
    rasterizationOptions.PageWidth = 1600;
    rasterizationOptions.PageHeight = 1600;
    PdfOptions pdfOptions = new PdfOptions { VectorRasterizationOptions = rasterizationOptions };

    cadImage.Save(outPath, pdfOptions);
    }