Hyperlink in Presentation Gets Applied to the Entire Paragraph instead of Portion in C#

I am trying to add a hyperlink to a portion of the paragh, but the hyperlink gets applied to the entire paragraph.

For eg, in the code below, I have added hyperlink to one portion in a paragraph (as attached in the sample ppt), and trying to replace the hyperlink of that portion.

Expected behaviour: only that portion which had a hyperlink before, should have the newly assigned hyperlink

Actual behaviour: the entire paragraph gets linked to that URL.

foreach (var curPara in curAutoShape.TextFrame.Paragraphs)
{
    foreach (var curPortion in curPara.Portions)
    {
        if (curPortion.PortionFormat.HyperlinkClick != null)
             curPortion.PortionFormat.HyperlinkClick = new Hyperlink("www.aspose.com");
    }
}

@gssnhimabindu,
Thank you for contacting support.

Please check your results using the latest version of Aspose.Slides for .NET if possible. If the issue persists, please share the following files and information:

  • sample presentation file
  • output presentation file
  • .NET target platform in your app
  • Aspose.Slides version you used

You can zip the files and upload an archive here.

I have tried with the latest aspose version (23.8), still facing the same issue. I have attached the sample ppt in the zip file attached.

abcbackup.zip (28.1 KB)

@gssnhimabindu,
Unfortunately, I was unable to reproduce the problem you described. Here is my complete code example:

using var presentation = new Presentation("abcbackup.pptx");

foreach (var shape in presentation.Slides[0].Shapes)
{
    if (shape is IAutoShape curAutoShape)
    {
        foreach (var curPara in curAutoShape.TextFrame.Paragraphs)
        {
            foreach (var curPortion in curPara.Portions)
            {
                if (curPortion.PortionFormat.HyperlinkClick != null)
                    curPortion.PortionFormat.HyperlinkClick = new Hyperlink("www.aspose.com");
            }
        }
    }
}

presentation.Save("output.pptx", SaveFormat.Pptx);

Output: output.zip (27.8 KB)

Please clarify how to reproduce the problem on our end.