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

Free Support Forum - aspose.com

TextStyle not fully applied to changed textNode

Hi Aspose team,

my scenario is that I open OneNote document and search for particular string.
For example: word "oliver" which has to be replaced with ASPOSEASPOSEASPOSE.

In my test document "test.one" which is in project debug folder I have http://www.oliver.com which is at the same time also hyperlink with appropriate text style.

When change is done text formatting is applied only to the same number of characters like www.oliver.com (first 14 characters) which looks like after change:

www.ASPOSEASPOSEAPSOSE.com


How can I enforce same formatting to complete textNode with changed/increased number of characters? I need to have following output www.ASPOSEASPOSEAPSOSE.com


Test project is attached together with test document.


Thanks,

Oliver

Hi Oliver.


Thanks for contacting us. One thing you have to do is to specify TextStyle.RunIndex property, which tells where a style of a text ends. In your case it should be something like this:

style.HyperlinkAddress = dh.ReplaceString(style.HyperlinkAddress, “oliver”, “ASPOSEASPOSEAPSOSE”);
style.RunIndex = 26;//this style will be applied to characters from 0 to 25.

If you want to combine regular text and hyperlink in a single RichText node, you can use this code nippet:

var textStyleRed = new TextStyle
{
FontColor = Color.Red,
FontName = “Arial”,
FontSize = 10,
RunIndex = 8//this style will be applied to 0-7 characters.
};
var textStyleHyperlink = new TextStyle
{
RunIndex = 17,//this style will be applied to 8-16 characters.
IsHyperlink = true,
HyperlinkAddress = www.google.com
};
var text = new RichText(doc)
{
Text = “This is hyperlink. This text is not a hyperlink.”,
DefaultStyle = defaultTextStyle,
Styles = { textStyleRed, textStyleHyperlink }
};
Hi Dmitry,

thanks for quick reply.


This gives good direction but I have next question - when I start to type in OneNote anything which starts with www. OneNote will convert it in Hyperlink.

When I try to use Aspose.Note over this type of note I see that style.IsHyperlink is set to true but style.HyperlinkAddress = "".

If I manually change link (right-mouse click and then Edit Hyperlink => fill Address field with hyperlink) everything works ok.

Is this by design or something to fix?

I attached two documents:
- GoogleTest.one where HyperlinkAddress is missing and
- 1GoogleTest.one where Hyperlink Address is available.

Thanks,
Oliver

Oliver,


This is how OneNote builds internal document structure. It doesn’t need any extra fields except IsHyperlink and RunIndex, in cases when hyperlink address is equal to the text. You can do the same thing as MS OneNote (getting HyperlinkAddress for IsHyperlink style using text between previous and current RunIndex). We also scheduled such task in our issue tracking system under ticket id NOTENET-1705.
We’ll keep you informed regarding any available updates.
Hi again,

I managed to processes hyperlinks in a way that I need plus to apply correct style.
It is also fine for me if you close the ticket NOTENET-1705 as I have workaround in place.

Thanks,
Oliver

Hi Oliver,


It’s nice to hear from you that the problem has been resolved. Please keep using the workaround till the fix of issue id NOTENET-1705. We’ll notify you once it is fixed and available for public use. Thank you for the cooperation.

  • The issues you have found earlier (filed as NOTENET-1705) have been fixed in this update.


    This message was posted using Notification2Forum from Downloads module by Aspose Notifier.