Exception while trying to convert DWG to PDF

We are trying to use Aspose.CAD to get pdfs from DWG files, and we are getting exceptions while trying to convert. The exception is not always the same, and it is not consistent, and loading and saving files directly from the disk or MemoryStreams seems to make a difference in the outcome as well.

My code is as follows:

string file = "path/to/dwg/file";

using (Aspose.CAD.Image image = Aspose.CAD.Image.Load(file))
{
    Aspose.CAD.ImageOptions.CadRasterizationOptions rasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions();
    rasterizationOptions.BackgroundColor = Aspose.CAD.Color.White;
    rasterizationOptions.PageWidth = 800;
    rasterizationOptions.PageHeight = 600;
    rasterizationOptions.DrawType = Aspose.CAD.FileFormats.Cad.CadDrawTypeMode.UseObjectColor;
    rasterizationOptions.GraphicsOptions.InterpolationMode = Aspose.CAD.InterpolationMode.Low;
    rasterizationOptions.GraphicsOptions.SmoothingMode = Aspose.CAD.SmoothingMode.None;
    rasterizationOptions.GraphicsOptions.TextRenderingHint = Aspose.CAD.TextRenderingHint.SystemDefault;
    rasterizationOptions.Quality.Arc = Aspose.CAD.ImageOptions.RasterizationQualityValue.Low;
    rasterizationOptions.Quality.Hatch = Aspose.CAD.ImageOptions.RasterizationQualityValue.Low;
    rasterizationOptions.Quality.Text = Aspose.CAD.ImageOptions.RasterizationQualityValue.Low;

    Aspose.CAD.ImageOptions.PdfOptions pdfOptions = new Aspose.CAD.ImageOptions.PdfOptions();

    pdfOptions.VectorRasterizationOptions = rasterizationOptions;

    var tempPath = "C:\\temp\\" + Path.GetRandomFileName();

    image.Save(tempPath, pdfOptions);

    var returnBytes = File.ReadAllBytes(tempPath);

    File.Delete(tempPath);

    return returnBytes;
}

The most common exception I get is this one:

Inner Exception Type: Aspose.CAD.CadExceptions.ImageSaveException
Inner Exception: Image export failed.
Inner Source: Aspose.CAD
Inner Stack Trace: 
   at Aspose.CAD.Image.SaveInternal(Stream stream, ImageOptionsBase optionsBase, Rectangle boundsRectangle)
   at Aspose.CAD.FileFormats.Cad.CadImage.SaveInternal(Stream stream, ImageOptionsBase optionsBase, Rectangle boundsRectangle)
   at  .(Object )
   at  .(MethodBase , Boolean )
   at  . ()
   at  .()
   at  .(Object )
   at  .()
   at  .(Object , UInt32 )
   at  .()
   at  .()
   at  . ()
   at  .(Object )
   at  .()
   at  .(Object , UInt32 )
   at  . ()
   at  .(Object[] , Type[] , Type[] , Object[] )
   at Aspose.CAD.Image.Save(Stream stream, ImageOptionsBase optionsBase, Rectangle boundsRectangle)
   at Aspose.CAD.Image.SaveInternal(String filePath, ImageOptionsBase options, Rectangle boundsRectangle)
Inner Exception Type: System.IndexOutOfRangeException
Inner Exception: Index was outside the bounds of the array.
Inner Source: Aspose.CAD
Inner Stack Trace: 
   at   .Export(Image , Stream , ImageOptionsBase , Rectangle )
   at Aspose.CAD.Image.SaveInternal(Stream stream, ImageOptionsBase optionsBase, Rectangle boundsRectangle)
Exception Type: Aspose.CAD.CadExceptions.ImageSaveException
Exception: Image saving failed.
Stack Trace: 
   at Aspose.CAD.Image.SaveInternal(String filePath, ImageOptionsBase options, Rectangle boundsRectangle)
   at Aspose.CAD.Image.Save(String filePath, ImageOptionsBase options, Rectangle boundsRectangle)
   at Aspose.CAD.Image.Save(String filePath, ImageOptionsBase options)

Some more info that maybe could help: This code is part of a WCF service that convert files to PDF. Each call this service receives, it fires a individual task to convert the file to PDF. We use multiple Aspose libraries in it, such as Words, Sheets and Email. It seems like the Exception is most likely to happen when you fire 2 DWG convertions at the same, but we managed to convert multiple DWGs at the same time and get the exception while converting only one DWG.

We are using the latest version of Aspose.CAD, 19.7.

estrutura-alterada.zip (424.1 KB)

@LuizEduardo,

I have worked with sample code and source file shared by you and unable to observe issue. I have also shared my generated result with you for your kind reference. Also please share environment details along with complete sample project so that we may investigate further.estrutura-alterada.pdf (1.1 MB)

I am attaching a sample project that has the same structure as my WCF Service for you to test. The service is running inside ISS on a Windows server, if you need any more specific info just ask and I will gladly provide.

AsposeSample.zip (12.9 KB)

@LuizEduardo,

Can you please share complete environment details and server details with us along with memory details as well so that we may further investigate to help you out.