We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Saving Bug

When changing a hyperlink it is not changed until the text is changed. See code below and the attached very simple PowerPoint file. When only the link is changed, it is not actually changed. The text needs to be changed as well (open bug2.pptx and edit hyperlink to see).

I need to be able to change the link without having to change the link text. Can you give me a workaround until you have a bug fix ready?


public static void Bug()
{
var path = @"c:\temp\bug.pptx";
var doc = new Presentation(path);
var shape = doc.Slides[0].Shapes[0];
ITextFrame textFrame = ((AutoShape)shape).TextFrame;
var portion = textFrame.Paragraphs[0].Portions[0];
portion.PortionFormat.HyperlinkManager.SetExternalHyperlinkClick(@"www.bing.com");
//uncomment the following line to have the link change take effect
// portion.Text += " ";
path = path.Replace(@"bug", @"bug2");
doc.Save(path, SaveFormat.Pptx);
}

Hi Thomas,


I have observed your comments. Can you please share environment details ,also please share which Aspose.Slides version you are using on your end so that we can further investigate to resolve the issue.

Best Regards,

I was using the version from January 2017. I upgraded to the Feb 2017 version (17.2) and the one bug was replaced with another.


Now the link changes but the text change does not take effect. Use the same file as above (bug.pptx) and then run the code below. Please look at the resulting file (bug2.pptx) and notice that the link text incorrectly states bing.com. This happens if I remove the line that changes the text or if I assign a different url. It does however work if I put some other (non-url) text there.

public static void Bug()
{
AsposeLicenseManager.License(PptFileHandler.License, stream => PptFileHandler.License.SetLicense(stream));
var path = @“c:\temp\bug.pptx”;
var doc = new Presentation(path);
var shape = doc.Slides[0].Shapes[0];
ITextFrame textFrame = ((AutoShape)shape).TextFrame;
var portion = textFrame.Paragraphs[0].Portions[0];
portion.PortionFormat.HyperlinkManager.SetExternalHyperlinkClick(@“http://www.bing.com”);
//2 bugs: 1. The link text changes to bing.com and 2. even setting it to something else does not fix it
portion.Text = “http://www.yahoo.com”;
path = path.Replace(@“bug”, @“bug2”);
doc.Save(path, SaveFormat.Pptx);
}
There is a related bug. When I change a link where the link text contains not just a link but some added text, that added text is removed! Please don't do that. Don't be "smart", let me be in control or at least provide an option to turn off your automatic changing of the text without my input.

See the attached file "pp.pptx" and the code below to reproduce this.

{
var path = @"c:\temp\pp.pptx";
var doc = new Presentation(path);
var shape = doc.Slides[0].Shapes[0];
ITextFrame textFrame = ((AutoShape)shape).TextFrame;
var paragraph = textFrame.Paragraphs[0];
paragraph.JoinPortionsWithSameFormatting();
var portion = paragraph.Portions[0];
string url = portion.PortionFormat.HyperlinkClick.ExternalUrl;
string originalText = portion.Text;
string updatedUrl = url.Replace("keysight", "agile");
portion.PortionFormat.HyperlinkManager.SetExternalHyperlinkClick(updatedUrl);
var updatedPath = path.Replace(@"pp.", @"pp2.");
doc.Save(updatedPath, SaveFormat.Pptx);
doc = new Presentation(updatedPath);
shape = doc.Slides[0].Shapes[0];
textFrame = ((AutoShape)shape).TextFrame;
paragraph = textFrame.Paragraphs[0];
paragraph.JoinPortionsWithSameFormatting();
portion = paragraph.Portions[0];
Debug.Assert(portion.Text.EndsWith(originalText));
}

Hi Thomas,


I have observed your comments. A ticket with ID SLIDESNET-38423 has been added in our issue tracking system to resolve the issue. This thread has been associated with the ticket so that we share notification with you once issue will be fixed.

We are sorry for your inconvenience,