Chart X-Axis Labels Appear Slanted When Converting a Slide to an Image in C#

Hi Team,

I have a PPTX (attached) with 1 slide. Slide has a Chart. When I try to get image of the slide, I see that the labels on the x-axis appear slanted while in the ppt they are straight.

The code I used:

using Aspose.Slides;
using Aspose.Slides.Export;
using Aspose.Slides.Animation;
using Aspose.Slides.Charts;
using Aspose.Slides.SmartArt;
using Aspose.Slides.Ink;
using System.Drawing;
using System.Drawing.Imaging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using System.Collections;
using System.Xml;
using System.Threading;
using System.Reflection;
using System.IO;
using System.Drawing.Text;
class Program
{
    static void Main(string[] args)
    {
        try
        {

            // Load the presentation
            using (Presentation presentation = new Presentation("sample.pptx"))
            {
                Console.WriteLine("Number of slides in the presentation: " + presentation.Slides.Count);
                
                // Create output directory if it doesn't exist
                string outputDir = "slide_images";
                if (!Directory.Exists(outputDir))
                {
                    Directory.CreateDirectory(outputDir);
                }
                
                // Convert each slide to image
                for (int i = 0; i < presentation.Slides.Count; i++)
                {
                    ISlide slide = presentation.Slides[i];
                    
                    // Create a full scale image
                    using (IImage image = slide.GetImage(1.0f, 1.0f))
                    {
                        string fileName = Path.Combine(outputDir, $"slide_{i + 1}.png");
                        image.Save(fileName, Aspose.Slides.ImageFormat.Png);
                        Console.WriteLine($"Saved slide {i + 1} as {fileName}");
                    }
                }
                
                Console.WriteLine($"\nAll slides exported to images in '{outputDir}' folder");
            }
        }
        catch (Exception ex)
        {
            Console.WriteLine($"An error occurred: {ex.Message}");
        }
    }
}

I used Aspose version 25.5. Pls find attached the output image as well.

Could you pls help me resolve this issue ? Thank you,
slide_1.png (38.4 KB)

sample.zip (37.8 KB)

@bhav

It sounds like you’re experiencing an issue with the x-axis labels appearing slanted when converting your PowerPoint slide to an image. This can occur due to rendering settings or the formatting of the chart in the original presentation.

Cause: The slanted x-axis labels may result from incorrect chart formatting or suboptimal rendering options during the conversion process.

Solution: Here are several steps to troubleshoot and resolve the issue:

  1. Check Chart Formatting: Ensure that the x-axis labels in your chart are formatted correctly in PowerPoint. Adjusting the angle of the labels directly in PowerPoint can often resolve the issue.

  2. Rendering Options: When converting the slide to an image, use rendering options that can improve the layout. You can specify custom rendering options to control how the slide is rendered.

  3. Update Aspose.Slides: Since you are using version 25.5 of Aspose.Slides, consider updating to the latest version. Newer versions may include improvements and bug fixes related to rendering charts and text.

  4. Custom Image Size: If you haven’t done so already, specify a custom size for the image when calling the GetImage method. This can help address layout issues.

Here’s a code snippet that demonstrates how to set custom rendering options:

using Aspose.Slides;
using Aspose.Slides.Export;
using System.Drawing;

class Program
{
    static void Main(string[] args)
    {
        using (Presentation presentation = new Presentation("sample.pptx"))
        {
            IRenderingOptions options = new RenderingOptions();
            // Set any specific options you need here

            // Convert the first slide to an image with custom options
            using (IImage image = presentation.Slides[0].GetImage(options, 1.0f, 1.0f))
            {
                image.Save("Slide_1.png", ImageFormat.Png);
            }
        }
    }
}

Next Steps: Try these steps and see if they help resolve the issue with the slanted x-axis labels. If the problem persists, please share more details about your setup, and I will be happy to assist you further! Thank you for your patience.

@bhav,
Thank you for reporting the issue. I have reproduced the issue of slanted axis labels when converting the slide to an image. We apologize for any inconvenience caused.

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): SLIDESNET-45073

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.

The issues you found earlier (filed as SLIDESNET-45073) have been resolved in Aspose.Slides for .NET 25.9 (ZIP, MSI, NuGet, Cross-platform).
You can check all fixes on the Release Notes page.
You can also find the latest version of our library on the Product Download page.