Can't load .cdr file in .NET (CorelDraw X5 later version)

Hello.

I have successfully opened the .cdr file using the image viewer provided by the Aspose website.
(https://products.aspose.com/imaging/net/viewer/cdr/)

I tried to load the image using the .NET code just below the image viewer, but I got an error.
(ImageLoadException: Cannot open an image. The image file format may be not supported at the moment.)

I tried to load a .cdr file using this code:

using (var image = Aspose.Imaging.Image.Load(inputPath))
{
	// Do Something..
}

I analyzed the file headers of the files that are loaded and those that are not.
Files that are loaded on my app: RIFF-based header
Files that are not loaded on my app: ZIP-based header
(PS: From CorelDraw X5 and later, the header has been changed to ZIP-based.)

Can you help me?
(I’m using Aspose.Imageing for .NET 24.12.0)

@dev9

It seems you are encountering an ImageLoadException when trying to load a .cdr file using Aspose.Imaging for .NET. This error typically indicates that the library is unable to recognize or support the file format you are trying to load.

Here are a few steps you can take to troubleshoot and resolve this issue:

  1. Check File Format Compatibility: Ensure that the .cdr file you are trying to load is supported by the version of Aspose.Imaging you are using. Aspose.Imaging for .NET has specific support for CorelDRAW files, and it’s important to verify that your file is in a compatible format.

  2. Use the Correct Load Method: Make sure you are using the Image.Load method correctly. Here’s a sample code snippet to load a .cdr file:

    using Aspose.Imaging;
    
    class Program
    {
        static void Main(string[] args)
        {
            // Specify the path to your CDR file
            string filePath = "path/to/your/file.cdr";
    
            // Load the CDR file
            using (Image image = Image.Load(filePath))
            {
                // Check if the loaded image format is CDR
                if (image.FileFormat != FileFormat.Cdr)
                {
                    throw new Exception("The loaded image is not in CDR format.");
                }
            }
        }
    }
    

    Make sure to replace "path/to/your/file.cdr" with the actual path to your .cdr file.

  3. Update Aspose.Imaging: Since you are using version 24.12.0, consider checking if there are any updates or patches available for Aspose.Imaging that might address loading issues with .cdr files. Sometimes, newer versions include bug fixes and enhancements for file format support.

  4. Test with Different Files: If possible, try loading different .cdr files to see if the issue is specific to the file you are using. This can help determine if the problem lies with the file itself or with the library.

If you continue to experience issues, I recommend reaching out to the Aspose community or support for further assistance, as they may have more specific insights into the problem you are facing.

Sources:
[1]: Support of CDR Format with Aspose.Imaging for .NET

I tried to load a .cdr file using this code:

using (var image = Aspose.Imaging.Image.Load(inputPath))
{
	// Do Something..
}

But I got an error in the Load function.
I have two files, A and B, and I checked that they are both loaded on the Aspose website.
However, in my .NET application, file A is loaded, but file B is getting an error when I try to load it.

I analyzed the file headers of the files that are loaded and those that are not.
Files that are loaded: RIFF-based header
Files that are not loaded: ZIP-based header

PS: From CorelDraw X5 and later, the header has been changed to ZIP-based.

@dev9 The Aspose.Imaging library supports cdr files of later versions than x5, up to the latest versions of Corel Draw.
Could you please provide a sample of a non-working file for analysis and a more precise answer.

files.zip (1.1 MB)

I have attached 2 files as a zip file.
successed.cdr: Loads normally in .NET environment using Aspose.Imaging.
failed.cdr: Error occurs when loading using Aspose.Imaging.

@stanislav.popov
I have attached the file and wrote a reply.
Please check my reply.
Thanks.

@stanislav.popov
PS.
I have a WinForm project based on .net6-windows.
I used Aspose.Imaging.dll based on netstandard2.0 of Aspose.Imaging 24.12.0 version in this project.

@dev9 Thank you for the information provided, I will check it soon and let you know.

On my PC - “failed.cdr” converts without problems.
I have attached the result and the test application. Please check and let me know if you cannot convert in the attached application.
failed.cdr.png (10.7 KB)
WinFormsApp1.zip (1.1 MB)

@stanislav.popov

I have verified that the project you provided is working fine on my pc.
The difference between you and me is that I downloaded the dll from Aspose website, but you got it from Nuget.
I will test it again after referencing Aspose.Imaging from Nuget.
Thank you very much for your help.
Have a nice day.

Thank you for contacting us, have a nice day!