X-Axis Title Is Cut Off When Converting a Presentation Chart to an Image in C#

Hi Team,

I have a sample PPTX with a single slide having a single shape. When I get an image of this shape using Aspose, I see that the text “Time, t, in seconds” appears to be cut. I am using Aspose 25.5 version.

Code:

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

class Program
{
    static void Main(string[] args)
    {
        try
        {
            // Load the presentation
            using (Presentation presentation = new Presentation("sample.pptx"))
            {

                int shapeCounter = 1;

                // Loop through all slides
                for (int slideIndex = 0; slideIndex < presentation.Slides.Count; slideIndex++)
                {
                    // Get current slide
                    ISlide slide = presentation.Slides[slideIndex];

                    // Process each shape in the current slide
                    foreach (var curShape in slide.Shapes)
                    {
                        using (var curImage = curShape.GetImage())
                        {
                            // Save the image with a unique name including slide number
                            string fileName = $"slide_{slideIndex + 1}_shape_{shapeCounter}.png";
                            curImage.Save(fileName, Aspose.Slides.ImageFormat.Png);
                            Console.WriteLine($"Image saved successfully as {fileName}");
                            shapeCounter++;
                        }
                    }
                }
            }
        }
        catch (Exception ex)
        {
            Console.WriteLine($"An error occurred: {ex.Message}");
        }
    }
}

sample.zip (46.5 KB)

Screenshot (112).png (124.2 KB)

Kindly help us resolve this issue. Thanks,

@bhav

@bhav

It seems that you are experiencing an issue where the text in your shape is being cut off when you extract it as an image using Aspose.Slides. This problem has been reported by other users as well, particularly when the viewbox of the extracted shape is smaller than the actual content, leading to cropping.

To address this issue, you might want to consider the following steps:

  1. Update Aspose.Slides: Ensure that you are using the latest version of Aspose.Slides. The issue you are facing may have been resolved in more recent updates. For instance, a similar issue was fixed in version 24.3, so upgrading from version 25.5 to the latest version could potentially resolve your problem.

  2. Check Shape Properties: Before extracting the image, verify the properties of the shape. Sometimes, adjusting the size or position of the shape can help prevent text from being cut off.

  3. Use Different Export Methods: If the problem persists, consider using different methods for exporting the shape to an image. For example, you might try exporting the entire slide as an image instead of individual shapes to see if that resolves the issue.

  4. Report the Issue: If none of the above solutions work, you may want to report this issue to Aspose’s support team, providing them with details about your environment and the specific problem you are encountering.

If you need further assistance, feel free to ask!

Sources:
[1]: PowerPoint Shape Is Cropped (Cut Off) when Saving It as an SVG Image in C#

@bhav,
Thank you for reporting on the issue. I’ve reproduced the problem with displaying the X-axis title when converting the chart to an image.

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-44960

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.