Showing html in Windows Phone app - c#

I create application for read news, and I get content with server in the form of html code. I use standard WebView control for showing him, but it is not very well. Because this control you cannot change. And I founded HTMLTextBox but this control does not display youtube video. My question what control is best to use for this?

You have 3 solutions to display HTML :
Parse the HTML and display it with your own XAML. You could use the Html Agility Pack to parse the html you want.
Let someone parse the HTML for you and display it with a custom control like the HTMLTextBox you mentioned.
Let the browser parse the HTML for you and display it with the classic WebView. Note that you can add some css or js to enhance, improve or manage the html.

Related

how to print html content with embedded css, image and javascript?

Is there a way to parse html content which contains css and javascript, and then print it without having the computer to display the print dialog using c# desktop program?
The html may contain javascript that manipulate the DOM. For example :
<html><body><h1>Title</h1><script>document.write(Math.random())</script></body></html>
You want to load it into a WebBrowser object and then call the Print method
Although if you don't like IE you might want to look at Replacing .NET WebBrowser control with a better browser, like Chrome? for alternatives.

WPF WebBrowser control: Disable download or how to find out all displayable filetypes

I'm writing a document view and I'd like to use the capabilities of the WebBrowser control for some file formats (pdf, e-mail).
Now I have the problem, that for every file format that is unknown to the WebBrowser control, it offers to download the file.
So the question is: How to find out what file formats (file extensions) can be displayed by the browser, so that I can display a message to the user that the current fileformat is not supported for displaying instead of getting a "Do you want to download" dialog box.
If I was you I wouldn't use a WebBrowser control for following reasons:
WebBrowser is just a wrapper around IE engine. It uses old version of IE by default, so it can have troubles displaying correctly HTML documents with basic CSS styling. It can be forced to use newer versions of IE or even other engines, but it takes some effort.
WebBrowser control purpose is to display and navigate throught web pages. And navigating is essentially downloading. I believe it's gonna be hard if not impossible to prevent WebBrowser from downloading files. I believe one way you can do it is by modifying html files like this: Remove hyperlink but keep text? Also you would probably want to prevent context menu from openning.
WebBrowser control is capable of displaying PDF as described here Displaying a PDF in a WPF Application Not Working - WebBrowser or Adobe Control But I have no idea how would you prevent following the links placed in pdf
Instead of using WebBrowser I suggest you to use one of many royalty-free PDF viewing controls and convert your html documents to PDF. I believe suggested approach will take you less time and will be more robust

C# extract content from HTML document

I was wondering how can I do something similar to Facebook when a link is posted or like shortening link services that can get the title of the page and its content.
Example:
My idea is to get only the plain text from a web page, for example if the url is an article of a newspaper how can I get only the news's text, like showed in the image. For now I have been trying to use the HtmlAgilityPack but I can never get the text clean.
Note this app is for Windows Phone 7.
You're on the right track with HtmlAgilityPack.
If you want all the text of the website, go for the innerText attribute. But I suggest you go with the meta description tag (if available).
EDIT - Go for the meta description. I believe that's what Facebook is doing:
Facebook link sample
Site source

How do you display HTML in windows app?

I have a bunch of HTML code that I need to display in a label/textbox in a windows app written in c#. It should be in such a way that the output shows the HTML formatted text, rather than the HTML code itself.
How can I do this?
Render your HTML in WebBrowser control. It has special events for document and you can iterate by tags like this Hope it will help you;)
Check out WebBrowser
There's a web browser control using IE's rendering engine to display HTML content. You might as well be able to do some simple parsing yourself and use a RTF control but that way you will be rather restricted.
If WebBrowser doesn't suit your needs you can check out these libraries with HTML label/control support
Telerik Controls for WinForms (Not Free)
http://www.telerik.com/products/winforms.aspx
GDI+ HTMLRenderer (Free, Open Source)
http://www.codeproject.com/KB/GDI-plus/HtmlRenderer.aspx?msg=2934040
The HTML Editor (a wrapper for MSHTML, the rendering portion of Internet Explorer) in read-only mode might be what you need.

How to render HTML chunk?

What's the best way to render a chunk of HTML in an application? We have a rich text editor control (from Karamasoft) in a web page, and need to generate a PDF with records saved from the control (with custom page headers, page footers, and record headers) so I need to be able to render the html so it can be "drawn" onto the page to be saved as a pdf.... is there any staright forward simple way to do this?
HTML Renderer is a library of 100% managed code that draws beautifully formatted HTML.
Without using any libraries, you can use the Literal control that allows you to inject the HTML you wish to display to the user.
You may try PURE to render JSON data in HTML: http://beebole.com/pure/
Although this may be out of topic.
But then I'm interested on how do you convert the HTML in PDF.
What technical steps are involved?

Categories

Resources