gpt4 book ai didi

C# 从 html 字符串打印 html 文档

转载 作者:太空狗 更新时间:2023-10-30 01:17:19 25 4
gpt4 key购买 nike

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

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

Output: ...some html code...

最佳答案

正如我对您的理解正确,您需要 WebBrowser类:

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 文档,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32197373/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com