Aspose.CAD.CadExceptions.ImageSaveException occurs in coverting dwg to pdf

Hello.

I found an issue of dwg-to-pdf conversion.

Aspose.CAD.CadExceptions.ImageSaveException occurred at Aspose.CAD.Image.Save method.

Detailed error messages are the followings.
I translated some debugger text to English.

Aspose.CAD.CadExceptions.ImageSaveException was unhandled
HResult=-2146233088
Message=Image saving failed.
Source=Aspose.CAD
StackTrace:
Position: Aspose.CAD.Image.SaveInternal(String filePath, ImageOptionsBase options)
Position: Aspose.CAD.Image.Save(String filePath, ImageOptionsBase options)
Position: TestConsole.Module1.TestPDF() File TestConsole\Module1.vb:line 85
Position: TestConsole.Module1.Main() File TestConsole\Module1.vb:line 14
Position: System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
Position: System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
Position: Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
Position: System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
Position: System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
Position: System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
Position: System.Threading.ThreadHelper.ThreadStart()
InnerException: Aspose.CAD.CadExceptions.ImageSaveException
HResult=-2146233088
Message=Image export failed. Error during PDF export: Index is out of range. The index must not be negative and must be smaller than the size of the collection.
Parameter name: index
Source=Aspose.CAD
StackTrace:
Position: Aspose.CAD.Image.SaveInternal(Stream stream, ImageOptionsBase optionsBase)
Position: Aspose.CAD.Image.SaveInternal(String filePath, ImageOptionsBase options)
InnerException:
HResult=-2146233088
Message=Error during PDF export: Index is out of range. The index must not be negative and must be smaller than the size of the collection.
Parameter name: index
Source=Aspose.CAD
StackTrace:
Position: .Export(Image , Stream , ImageOptionsBase , Rectangle )
Position: Aspose.CAD.Image. . ()
Position: . ( , Int32 , )
Position: Aspose.CAD.Image.SaveInternal(Stream stream, ImageOptionsBase optionsBase)
InnerException: System.ArgumentOutOfRangeException
HResult=-2146233086
Message=Index is out of range. The index must not be negative and must be smaller than the size of the collection.
Parameter name: index
ParamName=index
Source=mscorlib
StackTrace:
Position: System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource)
Position: System.Collections.Generic.List`1.get_Item(Int32 index)
Position: . (Image , VectorRasterizationOptions , Int32 )
Position: . (CadRasterizationOptions )
Position: .Export(Image , Stream , ImageOptionsBase , Rectangle )
InnerException:

I attached dwg files which make error.
dwg.zip (1.3 MB)

Best regards.

@dark,

I have observed the stack trace shared by you and request you to please share the working sample code reproducing the issue on your end.

My test code is as the following;

Private Sub TestPDF()
    Dim sourceFile As String = "D:\temp\test.dwg"
    Dim outputFile As String = "d:\temp\" & IO.Path.GetFileNameWithoutExtension(sourceFile) & ".pdf"

    Dim image As Aspose.CAD.Image
    image = Aspose.CAD.Image.Load(sourceFile)

    Dim cadImage As Aspose.CAD.FileFormats.Cad.CadImage = image

    Dim rasterizationOptions = New Aspose.CAD.ImageOptions.CadRasterizationOptions()

    With rasterizationOptions
        .BackgroundColor = Aspose.CAD.Color.White
        .DrawType = FileFormats.Cad.CadDrawTypeMode.UseObjectColor
        .AutomaticLayoutsScaling = True
        .NoScaling = False
    End With

    Dim pdfOptions = New Aspose.CAD.ImageOptions.PdfOptions()
    pdfOptions.VectorRasterizationOptions = rasterizationOptions

    cadImage.Save(outputFile, pdfOptions)
End Sub

@dark,

I have worked with sample DWG files and have been able to reproduce the issue. A ticket with ID CADNET-1109 has been created 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 CADNET-1109) have been fixed in this update.