We are facing an issue where Aspose.Note does not return the correct hyperlink address for hyperlinks which contain Unicode characters in their address. For those hyperlinks, it simply returns the hyperlink text as hyperlink address, which is not correct.
We have created a sample project to demonstrate this behavior. Please notice that for all the hyperlinks the hyperlink text is being retrieved correctly except the ones which contain Unicode characters.
If you will have difficulties downloading the project, you can simply download the sample file (the forum does not allow attaching files of .one format) and run the following code
public static void Main(string[] args)
{
string filePath = @"Test File\OneNoteTest.one";
using (FileStream fileStream = new FileStream(filePath, FileMode.Open))
{
Document doc = new Document(fileStream);
foreach (var page in doc)
{
IList<RichText> richTexts = page.GetChildNodes<RichText>();
foreach (RichText richText in richTexts)
{
foreach (TextRun textRun in richText.TextRuns)
{
var textStyle = textRun.Style;
if (textStyle.IsHyperlink && !string.IsNullOrWhiteSpace(textStyle.HyperlinkAddress))
{
string linkPath = textStyle.HyperlinkAddress;
string linkText = textRun.Text;
Console.WriteLine($"Link Text: {linkText}");
Console.WriteLine($"Link Path: {linkPath}");
Console.WriteLine("-----------------------");
Console.WriteLine();
}
}
}
}
}
Console.ReadKey();
}
After an initial testing, I was able to reproduce the issue as you mentioned by using your sample document. I found HyperlinkAddress is not correctly retrieved when unicode characters are found in the link path of the document.
We require thorough evaluation of the issue. 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): NOTENET-5832
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 have found earlier (filed as NOTENET-5832) have been fixed in this update. This message was posted using Bugs notification tool by senua.remizova
@amjad.sahi Unfortunately, the new update broke the old functionality we were relying on. It seems to us that all the links are getting trimmed now after the first “#” character, which causes us to not see all the information coming after this character (section-id, base-path, etc.).
This can be clearly be visible with the test application that we provided as part of this support ticket
Results previously (everything is being reported correctly except the unicode link path)
Link Text: Rename
Link Path: onenote:Rename.one#section-id={90E2A70A-EF2A-44A7-ACB3-3BDF5FD82FF3}&end&base-path=D:\OneNote%20Test
-----------------------
Link Text: Rename2
Link Path: onenote:#section-id={90E2A70A-EF2A-44A7-ACB3-3BDF5FD82FF3}&end&base-path=D:\OneNote%20Test\Rename.one
-----------------------
Link Text: Rename4
Link Path: onenote:Rename.one#base-path=D:\OneNote%20Test
-----------------------
Link Text: Rename5
Link Path: onenote:Rename.one#base-path=D:\OneNote%20Test
-----------------------
Link Text: ChildRename2
Link Path: onenote:Rename.one#section-id={D6FAB630-417A-4E4A-9AA3-9651D07A68E7}&end&base-path=D:\OneNote%20Test\Child
-----------------------
Link Text: AmpersandRename
Link Path: onenote:AAA%20&%20BBB\Rename.one#section-id={A7855CCF-6EB9-4C6C-858B-FA3383E07E58}&end&base-path=D:\OneNote%20Test
-----------------------
Link Text: UnicodeRename1
Link Path: UnicodeRename1
-----------------------
Results in the Aspose.Notes 24.7 version (all the link paths are being reported incorrectly)
Link Text: Rename
Link Path: onenote:Rename.one
-----------------------
Link Text: Rename2
Link Path: onenote:
-----------------------
Link Text: Rename4
Link Path: onenote:Rename.one
-----------------------
Link Text: Rename5
Link Path: onenote:Rename.one
-----------------------
Link Text: ChildRename2
Link Path: onenote:Rename.one
-----------------------
Link Text: AmpersandRename
Link Path: onenote:AAA%20&%20BBB\Rename.one
-----------------------
Link Text: UnicodeRename1
Link Path: onenote:
-----------------------
I did test your scenario/case using Aspose.Note for .NET 24.7 with your original OneNote document. You are right as I found all the links are getting trimmed now after the first “#” character. We have reopened your ticket “NOTENET-5832”. We will look into it to figure it out soon.
We would appreciate it if you could provide us with your expected results. What specific results are you looking to achieve using the Aspose.Note for .NET library? Once we have this information, we will be able to evaluate and incorporate any necessary enhancements to meet your needs.
@amjad.sahi We just want to get full hyperlink paths and link texts as they can be seen in the OneNote hyperlink editor itself.
This means that whatever format is used for the hyperlink there, the same we want to get in the result window. This means that all the results from the Aspose.Note version 24.6 (and prior versions) were expected and correct
We would like to be able to receive those kind of hyperlink paths the same way as they are being shown in the Microsoft OneNote’s “Edit Link” window.
P.S. Our product helps users to modify hyperlinks in various Microsoft Office filetypes. In order to accomplish the task for links containing unicode characters we first need to receive the hyperlink path as is (regardless of the characters used in the hyperlink path).
Thank you for providing details on your expected/desired results. I have logged the details with your existing ticket “NOTENET-5832” into our database. We will be looking into it soon.
Once we have an update, we will let you know here.
Once we have an update on it, we will let you know here.
We have further evaluated your requirements (expected results) and are pleased to inform you that our upcoming version (Aspose.Note for .NET 24.8) will include the fix/enhancement for your desired output. The next version is due in the second half of August next month.
@amjad.sahi We’ve checked the fix and we are quite happy with the fix. The unicode link path is now getting reported correctly along with all the other regular link paths.
The only issue that we have is with the link text. The link/anchor text is correct for all the links except the links which contain unicode characters. The sample file that we provided contained 2 links containing unicode characters - named “UnicodeRename1” and “UnicodeRename2” accordingly.
It is nice to know that the latest version fixes the issue for HyperlinkAddress when unicode characters are found in the link path. We will evaluate and try to fix the issue where link/anchor text not correct for unicode characters as per your needs. 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): NOTENET-5846
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 have found earlier (filed as NOTENET-5846) have been fixed in this update. This message was posted using Bugs notification tool by senua.remizova
@amjad.sahi We’ve verified and can confirm that Aspose.Note 24.9 fixes all the issues reported in this thread (NOTENET-5832 and NOTENET-5846). Thank you for your effort.