FixedHtmlTextBlock text cutoff

Oct 23, 2013 at 1:07 AM
Hello,

I'm using a FixedHtmlTextBlock that renders html text after downloading them from online. I've noticed that for text that are longer than 3300 characters, it'll cut off the rest.
Since the FixedHtmlTextBlock is based off of the original TextBlock, and the TextBlock is limited to 2048*2048 Characters, would this be the limiting factor?
http://stackoverflow.com/questions/16711338/wpf-textblock-inside-a-scrollviewer-cuts-off-some-text
Coordinator
Oct 23, 2013 at 8:32 AM
This is not an easy to solve problem... because simple splitting the text would introduce wrong line wrappings... Do you have some line breaks (\n) in your html or is it one big block of text? It should be possible to split the text at the \n and create multiple textblocks there...
Oct 23, 2013 at 8:27 PM
Yes there are line breaks as well as <br> breaks.

I'll give it a try with multiple FixedHTMLTextBlocks and let you know if it works inside of a scrollviewer.
Coordinator
Oct 23, 2013 at 8:45 PM
For big html data you should not use fixed because it loads the whole code, the htmltextblock supports virtualization and contains a scrollviewer. I may have an updated control for you tomorrow which may solve your problem... Stay tuned
Oct 23, 2013 at 9:16 PM
Sounds good, I'll wait for your reply. Thanks for looking into this.
Coordinator
Oct 23, 2013 at 9:59 PM
Ok update the library and use

((ParagraphGenerator) html.Generators["p"]).UseTextSplitting = true;

html is a FixedHtmlTextBlock.
This feature is COMPLETELY untested and it may not be working...

Can you give me a sample url to test the control and fix the problem?
Marked as answer by jangooni on 10/23/2013 at 8:21 PM
Oct 24, 2013 at 3:21 AM
Updated the library (both myToolKit, and extended) and it seems to be working now after testing. If I run into more issues I'll let you know.

There's no sample URL, but if you want sample text let me know.
Coordinator
Oct 24, 2013 at 6:13 PM
So setting this property works for you? Everything (the whole html content) is shown and the text is not truncated? Then I'll set this property to true by default...

Can you send me some sample HTML so that i can test it for myself (mail at rsuter dot com)?
Oct 25, 2013 at 5:21 AM
Hi guys!
Here's a simple code stopped to show a very simple html
                MyToolkit.Controls.FixedHtmlTextBlock wb = new MyToolkit.Controls.FixedHtmlTextBlock();
                wb.Margin = new Thickness(10, 5, 10, 15);
                wb.Html = HttpUtility.HtmlDecode(currPost.caption);
                ContentPanel.Children.Add(wb);
Html like this:
<p>Some caption</p>
Coordinator
Oct 27, 2013 at 4:52 PM
This works without problems in my WinRT sample app (can be downloaded from SVN). Have you tried using the newest source code?

Btw: HtmlDecode should not be needed...

Where are you using the control (WP or WinRT)?
Oct 27, 2013 at 5:50 PM
Problem is on WP8. Using current MyToolkit 2.0.8

HtmlDecode is needed for decode html encoded utf symbols
Coordinator
Oct 27, 2013 at 6:27 PM
Yes, but HtmlDecode is already called by the control internally, i think you do not need to call it yourself...

I extended the sample app (download the whole solution at https://xp-dev.com/svn/mytoolkit) and it works perfectly. Maybe it something with your XAML and the panel is not resized or something like that...
Oct 28, 2013 at 5:09 AM
Don't work for me.
I'v created clean single page WP8 project. Added MyToolkit via NuGet.
Added this code on MainPage
        protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            ContentPanel.Children.Add(new TextBlock()
            {
                Text = "Some Text before FixedHtmlTextBlock",
            });

            MyToolkit.Controls.FixedHtmlTextBlock wb = new MyToolkit.Controls.FixedHtmlTextBlock();
            wb.Margin = new Thickness(10, 5, 10, 15);
            wb.Html = "<p><span>Wolfspark is a wolf sanctuary spread over 25 acres in Merzig, Germany. It is home to 29 wolves &#8212; six distinct packs hailing from Europe, Siberia, Canada, the Arctic, and Mongolia. Researcher Werner Freund, 79, a former German paratrooper, established the sanctuary in 1972 and has raised more than 70 animals there over the last 40 years. He acquired the wolves as cubs from zoos or animal parks and has reared them mostly by hand. Werner has also taken to living closely with his wolves, behaving as an alpha male to earn their acceptance and respect. Reuters photographer <strong><a href=\"http://blogs.reuters.com/lisiniesner/\" target=\"_blank\">Lisi Niesner</a></strong> recently spent some time with Freund and his wolves, capturing the interactions between these old friends.  [<a href=\"http://www.dailymail.co.uk/news/article-2269114/Werner-Freund-Pensioner-spent-40-years-running-sanctuary-living-packs-wolves.html\" target=\"_blank\">Article</a>] </span></p>";
            ContentPanel.Children.Add(wb);

            ContentPanel.Children.Add(new TextBlock()
            {
                Text = "Some Text after FixedHtmlTextBlock",
            });
        }
And it didn't show.
Only texts
"Some Text before FixedHtmlTextBlock"
"Some Text after FixedHtmlTextBlock"
Coordinator
Oct 28, 2013 at 7:06 AM
Edited Oct 28, 2013 at 7:32 AM
Important note: You should always use HtmlTextBlock with HeaderTemplate and FooterTemplate than FixedHtmlTextBlock in a ScrollViewer with own elements as header and footer because the first variant provides list virtualization and has much better performance for big html content!

See https://mytoolkit.codeplex.com/wikipage?title=HtmlTextBlock

Ill look into the project..
Coordinator
Oct 28, 2013 at 7:13 AM
Btw: WP uses a 6/12 grid and not 10/15 grid..
Coordinator
Oct 28, 2013 at 8:39 AM
Ok, there was a problem with the NuGet dependencies (MyToolkit has not been automatically installed). You can update now to version 2.0.10 and everything should work...
Oct 28, 2013 at 5:13 PM
It's OK now
Oct 31, 2013 at 12:50 AM
Hey rsuter, found 2 things.
1.) When trying to display multiple <img> objects, it'll only display the first one. Here's a sample code I'm trying to display.
<tr class="message"><td class="message">This one will take a bit of time and manipulation. In order to unlock the achievement, you will need to create a 9-letter word that will span across both '<b>DW</b>' bonuses <u>at the same time</u>. You can do this in a local '<i>Pass & Play</i>' game.<br/><br/>...so choose a word based on your starting letters from here:<br/><a href="http://www.becomeawordgameexpert.com/wordlists9.htm" rel="external nofollow">http://www.becomeawordgameexpert.com/wordlists9.htm</a><br/><br/>You'll have to abuse the swap-tile feature, but if you keep doing that, the game will start giving you back the tiles you first swapped out. Just use what you don't want on another part of the board and hold or build part of the word you've selected, with the other tiles.<br/><br/>i.e,<br/><span class="quote">I used the word '<b>RETENTION</b>' spanning from the upper-right '<b>DW</b>' to the lower-right '<b>DW</b>'<br/><br/>- I started with a word that ended with an '<b>N</b>'. The '<b>N</b>' was positioned between the two '<b>DW</b>'s<br/>- Next, I built my letter up to the word '<b>EN</b>'<br/>- After a few turns, to '<b>TEN</b>'<br/>- A bit more tile-swapping and built it up to '<b>TENT</b>'<br/>- Now held the remaining tiles needed until I could complete the entire word 'RE<b>TENT</b>ION'</span>Just remember. You have to use both '<b>DW</b>' spaces at the same time. <br/><br/>Good luck.<br/><br/><br/><u>Edit 04.29.13</u>: Here's some visual aid.<br/><br/><div class="externalimage">
<img src="http://i39.tinypic.com/3328m5u.png" class="externalimage" alt="External image" title="External image"/></div><br/><div class="externalimage">
<img src="http://i41.tinypic.com/30tpcm1.png" class="externalimage" alt="External image" title="External image"/></div><br/><div class="externalimage">
<img src="http://i40.tinypic.com/4kvi9x.png" class="externalimage" alt="External image" title="External image"/></div><br/><div class="externalimage">
<img src="http://i44.tinypic.com/2n810x.png" class="externalimage" alt="External image" title="External image"/></div><br/><div class="externalimage">
<img src="http://i43.tinypic.com/53l8pc.png" class="externalimage" alt="External image" title="External image"/></div></td>
</tr>
here's the site I'm referencing this from: http://www.trueachievements.com/a172218/duplicate-achievement.htm

2.) If there's an image that has an href attached to it, it wont resolve the href. I'm not sure if that's by design or not though, since webpage links work fine.
I don't have an example of this yet, but I'll post if you need it.
Coordinator
Oct 31, 2013 at 7:51 AM
  1. The images are not directly accessible (try in browser)? Try other image urls...
  2. Links can only be created on text. I now added the code to simply suppress the link if theres a problem in the link tag (eg not text only). This can be extended in the LinkGenerator class....
You should download the source code in svn and debug your problem...