Hello,
I am trying to convert a CDR file to PDF using aspose imaging .net library(20.11). Getting out of memory exception while converting the file.
File link : test.cdr - Google Drive
Exception details:
Aspose.Imaging.CoreExceptions.ImageLoadException: Image loading failed. —> System.OutOfMemoryException: Exception of type ‘System.OutOfMemoryException’ was thrown.
at System.IO.MemoryStream.set_Capacity(Int32 value)
at System.IO.MemoryStream.EnsureCapacity(Int32 value)
at System.IO.MemoryStream.Write(Byte[] buffer, Int32 offset, Int32 count)
at ?? .?? , Int32 , Boolean )
at ?? .?? , CdrObject , Int32[] )
at ?? .?? , CdrObjectContainer , Int32[] )
at ?? .?? , CdrObject , Int32[] )
at ?? .?? )
at ?? .()
at Aspose.Imaging.FileFormats.Cdr.CdrImage…ctor(Stream stream, LoadOptions loadOptions)
at .Load(StreamContainer , LoadOptions )
at Aspose.Imaging.Image.(StreamContainer , LoadOptions )
— End of inner exception stack trace —
at Aspose.Imaging.Image.(StreamContainer , LoadOptions )
using (var img = Aspose.Imaging.Image.Load(filePath + “.cdr”))
{
CdrRasterizationOptions rasterizationOptions = new CdrRasterizationOptions();
rasterizationOptions.PageWidth = img.Width;
rasterizationOptions.PageHeight = img.Height;
// Save image to Pdf
PdfOptions exportOptions = new PdfOptions();
exportOptions.VectorRasterizationOptions = rasterizationOptions;
img.Save(filePath + “.pdf”, exportOptions);
return filePath + “.pdf”;
}
Am using the following code to convert file: