Layers missing when converting corel draw file to jpg or png

We are evaluating Aspose.Imaging for our corel draw files noticed that one of our test files have missing layers when converted to jpg or png. It also altered some of the layout of the text. Hope you could help me if this is a issue or missing code that i need.

Original file
image.png (44.3 KB)

Jpg
image.jpg (131.2 KB)

Png
image.jpg (128.7 KB)

Here is my code

private bool CreatePreviews(CreatePreviewMediaActionBase action)
{
    const int DpiResolution = 72;
    const string CdrFormat = "CDR";

    // Only process CDR files
    if (!action.EngineFormat.Equals(CdrFormat, StringComparison.OrdinalIgnoreCase))
    {
        throw new MediaEngineException("File not supported.", false);
    }

    var stopwatch = Stopwatch.StartNew();

    try
    {
        using var inputStream = File.OpenRead(action.Path);
        long fileSizeBytes = inputStream.Length;

        using var image = Image.Load(inputStream);
        // Cast to CdrImage to access pages
        CdrImage cdrImage = image as CdrImage;
        if (cdrImage == null)
        {
            throw new MediaEngineException("Failed to load CDR image.", false);
        }

        // Get pages array - for single page CDR, Pages will contain one page
        Image[] pages = cdrImage.Pages;
        int pageCount = pages.Length;
        int pageNumber = 1;

        // Generate a preview for each page
        foreach (Image page in pages)
        {
            // Calculate preview size
            int previewWidth;
            int previewHeight;
            action.CalculateImageSize(Convert.ToInt32(page.Width), Convert.ToInt32(page.Height), DpiResolution, out previewWidth, out previewHeight);

            // Get output path based on format
            string previewPath = App.GetTemporaryFile(action.PreviewFormat.ToString());

            // Configure rasterization options with white background
            VectorRasterizationOptions rasterizationOptions = new CdrRasterizationOptions
            {
                PageWidth = previewWidth,
                PageHeight = previewHeight
            };

            // Save based on the requested format
            switch (action.PreviewFormat)
            {
                case ImageFormat.Jpg:
                    var jpegOptions = new JpegOptions
                    {
                        Quality = 75,
                        VectorRasterizationOptions = rasterizationOptions
                    };
                    page.Save(previewPath, jpegOptions);
                    break;

                case ImageFormat.Png:
                    var pngOptions = new PngOptions
                    {
                        ColorType = Aspose.Imaging.FileFormats.Png.PngColorType.TruecolorWithAlpha,
                        PngCompressionLevel = PngCompressionLevel.ZipLevel9,
                        FilterType = Aspose.Imaging.FileFormats.Png.PngFilterType.None,
                        Progressive = true,
                        VectorRasterizationOptions = rasterizationOptions
                    };
                    page.Save(previewPath, pngOptions);
                    break;

                case ImageFormat.WebP:
                    var webpOptions = new WebPOptions
                    {
                        Lossless = true,
                        VectorRasterizationOptions = rasterizationOptions
                    };
                    page.Save(previewPath, webpOptions);
                    break;

                default:
                    throw ErrorHelper.CreateGraphicEngineFileFormatNotSupportedForThumbnailAndPreview(App, EngineId);
            }

            // Add preview with page number (1-based)
            action.Previews.Add(new Preview(previewPath, pageNumber, previewWidth, previewHeight));
            pageNumber++;
        }

        stopwatch.Stop();

        var additionalInfo = new Dictionary<string, string>
            {
                {"Function","AsposeImagingMediaEngine.CreatePreviews" },
                {"Duration", stopwatch.ElapsedMilliseconds.ToString()},
                {"FileSizeBytes", fileSizeBytes.ToString()},
                {"PageCount", pageCount.ToString()},
                {"OutputFormat", action.PreviewFormat.ToString()}
            };

        App.WriteTrace("AsposeImagingMediaEngine", TraceSeverity.Information, additionalInfo);

        return true;
    }
    catch (ImageLoadException ex)
    {
        stopwatch.Stop();
        App.Log(LogSeverity.Error, "AsposeImagingMediaEngine.CreatePreviews: CDR files are not supported or corrupted", ex);
        throw new MediaEngineException("CDR files are not supported or corrupted.", ex, false);
    }
    catch (Exception ex)
    {
        stopwatch.Stop();
        App.Log(LogSeverity.Error, "AsposeImagingMediaEngine.CreatePreviews: An error occurred during the create preview process", ex);
        throw new MediaEngineException("An error occurred during the create preview process.", ex, false);
    }

}

I’ve also attached the files for your reference
testFiles.zip (2.5 MB)

Could you also let me know the expected output if the CDR contains a transparent background and converted to png. Does it support transparent or the image will just have a white background with red border?

@3stan

Summary
When a Corel DRAW (CDR) file is rasterized with Aspose.Imaging, some layers or text may not appear exactly as in the original. The SDK rasterizes the page onto a bitmap, and any features that are not fully supported (certain layer types, effects, or missing fonts) can be omitted or rendered differently. By default the rasterizer uses an opaque background, so a transparent background in the CDR will be rendered as a solid colour unless you explicitly change the background handling.

Why it happens

  • Partial CDR support – Aspose.Imaging does not implement every CDR feature. Objects that rely on unsupported effects, hidden layers, or special blend modes may be dropped during rasterization.
  • Background handling – If no background colour is specified, the rasterizer fills the canvas with white (or the default colour). Consequently a transparent background in the source CDR will not be preserved in the output image.
  • Font availability – When the fonts used in the CDR are not installed on the machine, the library substitutes them, which can change the appearance and positioning of text.
  • Version differences – Earlier releases of the library had more limitations with CDR files; newer releases contain improvements, but some edge‑cases may still exist.

What to do next

  1. Use the latest Aspose.Imaging version – Upgrade to the most recent release and re‑run the conversion. Many CDR‑related issues have been addressed in recent updates.
  2. Check background settings – If you need a transparent PNG, configure the rasterization options (if the API provides a background‑colour property) to use a transparent colour before saving as PNG.
  3. Verify layer visibility – Inspect the CdrImage object for layer information (e.g., cdrImage.Layers) and ensure that required layers are marked visible before rasterizing.
  4. Make required fonts available – Install any custom fonts used in the CDR on the conversion machine, or embed the fonts in the CDR file beforehand to avoid substitution.
  5. Provide a minimal reproducible sample – If the problem persists, create a small CDR file that demonstrates the missing layers or text, and include details such as the Aspose.Imaging version, OS, and runtime. This will help the support team determine whether the behaviour is a limitation or a bug.

Following these steps should help you obtain PNG output with the desired background handling and identify why certain layers are omitted.

Note: The above guidance is based on general Aspose.Imaging behaviour. For precise API names and property support, refer to the official Aspose.Imaging documentation for the version you are using.

:warning: I could not fully verify this explanation against the retrieved sources. Please double-check the behaviour in your environment and confirm the exact SDK/version.

@3stan hi.

This looks like a complex issue.

  1. Looks like the library does not have access to the fonts and a result Sans is used instead of Serif. What OS do you use?

  2. Missing layers. If I understand correctly, we are talking here about shark’s teeth and nose. Looks like it’s on our side. We’ll research it.

  3. Background color. To achieve the transparent background you can use

VectorRasterizationOptions rasterizationOptions = new CdrRasterizationOptions
{
    BackgroundColor = Color.Transparent,
};

I simplified a bit your code while testing and recieved these two results with the following code:

using var inputStream = File.OpenRead(inputPath);
using var image = (CdrImage)Image.Load(inputStream);
int pageNumber = 1;

foreach (Image page in image.Pages)
{
    VectorRasterizationOptions rasterizationOptions = new CdrRasterizationOptions
    {
        BackgroundColor = Color.Transparent,
        PageWidth = Convert.ToInt32(page.Width),
        PageHeight = Convert.ToInt32(page.Height)
    };

    var pngOptions = new PngOptions
    {
       
        ColorType = Aspose.Imaging.FileFormats.Png.PngColorType.TruecolorWithAlpha,
        PngCompressionLevel = PngCompressionLevel.ZipLevel9,
        FilterType = Aspose.Imaging.FileFormats.Png.PngFilterType.None,
        Progressive = true,
        VectorRasterizationOptions = rasterizationOptions
    };
    page.Save(previewPath + pageNumber + ".png", pngOptions);

    pageNumber++;
}

result.png (26.2 KB)
result1.png (29.0 KB)

As you can see the layers issue is reproduced with default VectorRasterizationOptions, and can be avoided with transparency. However, I don’t have fonts issue on the PC with Windows 11.

hi @Nikita_Romanov,

I am on the same team with @3stan. Unfortunately, he is out and will return on Monday. We’ll review your message when he returns by then.

@3stan
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): IMAGINGNET-7885

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

After some more research I found out that cdr file uses AlternateGothic2 font that is not installed in the OS and as a result the font manager takes the font that is believed to make sense.
To achieve a propert result please install the required font in your system.

I’ve applied the code BackgroundColor = Color. Transparent on my code for png but it did not resolved the missing part of the image.

image.jpg (134.7 KB)

Tested also on other output file (jpg, webp) and same result. Hope this will be the issue needed to be fix on the ticket attached to this support thread?

As for the font, this is expected and we are aware of the missing font type

The issue is related to incorrect background placement.
It should fix the problem regardless of whether BackgroundColor is used.

Oh, I see. As there were no watermarks on your original files I assumed you are not in the evaluation mode. The evaluation mode is limited in working with transparency and you cannot save transparent files.

I’ll attach the PNG and WebP samples of the library output with transparency and the settings I used so you can evaluate the results.
output.zip (85.7 KB)

PNG format supports transparensy, you need to set it in CdrRasterizationOptions and PngOptions:

    var rasterizationOptions = new CdrRasterizationOptions
    {
        BackgroundColor = Color.Transparent,
    };
    var pngOptions = new PngOptions
    {
        // the next two lines are important for the transparency
        ColorType = Aspose.Imaging.FileFormats.Png.PngColorType.TruecolorWithAlpha,
        VectorRasterizationOptions = rasterizationOptions,
        PngCompressionLevel = PngCompressionLevel.ZipLevel9,
        FilterType = Aspose.Imaging.FileFormats.Png.PngFilterType.None,
        Progressive = true,
    };

WebP format also supports transparensy:

    var rasterizationOptions = new CdrRasterizationOptions
    {
        BackgroundColor = Color.Transparent,
    };
    var webpOptions = new WebPOptions
    {
        Lossless = true,
        VectorRasterizationOptions = rasterizationOptions,
    };

JPEG format does not support transparensy at all so setting BackgroundColor to Transparent wouldn’t change anything.

1 Like