How to Print HTML content...
-
I have HTML content/text in a string variable and i want to print that (which looks like the one that appear on the browser). I found the below code in Code project only and i used the same: using HtmlPrinter; HtmlPrinter.HtmlPrinter hpobj = new HtmlPrinter.HtmlPrinter(); hpobj.PrintHtml(txtString.Text,true); But it is not workin for me. It is giving the following error: "ActiveX control '8856f961-340a-11d0-a96b-00c04fd705a2' cannot be instantiated because the current thread is not in a single-threaded apartment." How can i fix this bug? What did i miss here? Any work arounds please... Really appreciable if you can help me...
Srini Hyderabad
-
I have HTML content/text in a string variable and i want to print that (which looks like the one that appear on the browser). I found the below code in Code project only and i used the same: using HtmlPrinter; HtmlPrinter.HtmlPrinter hpobj = new HtmlPrinter.HtmlPrinter(); hpobj.PrintHtml(txtString.Text,true); But it is not workin for me. It is giving the following error: "ActiveX control '8856f961-340a-11d0-a96b-00c04fd705a2' cannot be instantiated because the current thread is not in a single-threaded apartment." How can i fix this bug? What did i miss here? Any work arounds please... Really appreciable if you can help me...
Srini Hyderabad
Hi, Why don't you try using DHTMLEditClass and set the DocumentHTML property with the HTML text you are having. You can then make use of PrintDocument method and pass 1 as a ref parameter to show the print dialog. You can get some help from MSDN as well. Hope it solves all your issues. Thanks Sameer