Underline Gets Cut When Converting a Presentation Shape to an Image in C#

Hi Team,

I have a sample PPTX with a single slide. The slide has a text with an underline. When I get the image of this text using Aspose, I see that the underline is partially cut. I am using Aspose 25.5 version.

The 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 (36.3 KB)

Screenshot (111).png (56.7 KB)

Pls help us resolve this issue. Thanks,

@bhav

@bhav

It seems that you are experiencing an issue where the underline in your text is being partially cut off when you extract images from a PowerPoint slide using Aspose.Slides. This problem may be related to how the shapes are being rendered or cropped during the image extraction process.

There has been a similar reported issue where shapes were cropped when saving them as SVG images, which indicates that the rendering might not be accounting for the full dimensions of the text, including underlines. This issue has been documented and a ticket has been opened for it, which suggests that it is recognized by the Aspose team.

To address this issue, I recommend 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 a newer release. For instance, a previous version (24.3) addressed similar cropping issues. You can download the latest version from the Aspose website.

  2. Check Shape Properties: When extracting images, check if there are any properties related to padding or margins that can be adjusted to ensure the underline is fully visible.

  3. Contact Support: If the issue persists after updating, consider reaching out to Aspose support with your specific case, including the sample PPTX file and the code you are using. They may provide a workaround or a fix.

If you continue to have trouble, please let me know, and I can assist you further!

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 the Underline style when converting the shape 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-44959

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.