C# 从 html 字符串打印 html 文档 [英] C# print html document from html string

查看:45
本文介绍了C# 从 html 字符串打印 html 文档的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

string s="<html><body>..some html code..</body></html>";

如何在没有PrintDialog的情况下打印文档?

How to print document without PrintDialog?

输出:...一些html代码...

Output: ...some html code...

推荐答案

按照我的理解,您需要 WebBrowser 类:

As I understood you correctly, you need WebBrowser class:

WebBrowser webBrowser = new WebBrowser();
void Print(string str)
{
   webBrowser.DocumentText = str;
   webBrowser.DocumentCompleted += webBrowser_DocumentCompleted;
}
void webBrowser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
   webBrowser.Print();
}

这篇关于C# 从 html 字符串打印 html 文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆