1

I have a c# WPF app that emails a report which is a string containing HTML markup, using ms outlook interoperability I can specify the email message format should be rendered in HTML. So my email is rendered in HTML from a string containing HTML markup. This works fine, my email shows a rendered table from my HTML string.

BUT I also need to print this report using WPF but when I use the same string containing the HTML markup tags, the printout does not perform the rendering I just get an exact copy of the HTML text. So my print out never displays the table.

Can someone please tell me how I can use WPF to print a string containing HTML tags so that the content is rendered before it is printed out, like in my email example ??

Many thanks in advance

2
  • By "print", do you mean real paper or just "display"? I think your title probably should be "Displaying HTML content in WPF". Commented Jul 3, 2011 at 14:20
  • Hi, I mean on real paper, I don't get the table rendered like I do when I email to outlook Commented Jul 3, 2011 at 15:04

1 Answer 1

2

Rendering HTML is not a trivial issue.

You could use a WebBrowser to do that for you, or you could use a HTML to FlowDocument converter of sorts, the document then could be displayed in a FlowDocumentScrollViewer. There is no direct support for HTML in WPF.

Sign up to request clarification or add additional context in comments.

2 Comments

Hi H.B Our email and printing service exist in their own service assembly. Will the web browser control still work?
I don't know, that depends on how you print, if you print WPF controls you should be able to use both of my proposed methods, if you have a more low-level approach which just handles strings as input that won't do.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.