private void PrintHelpPage()
{
// Create a WebBrowser instance.
WebBrowser webBrowserForPrinting = new WebBrowser();
WebBrowser webBrowserForPrinting1 = new WebBrowser();
// Add an event handler that prints the document after it loads.
webBrowserForPrinting.DocumentCompleted +=
new WebBrowserDocumentCompletedEventHandler(PrintDocument);
webBrowserForPrinting1.DocumentCompleted +=
new WebBrowserDocumentCompletedEventHandler(PrintDocument);
// Set the Url property to load the document.
webBrowserForPrinting.Url = new Uri(@"F:\fichinha.html");
webBrowserForPrinting1.Url = new Uri(@"F:\fichinha2.html");
}
private void PrintDocument(object sender, WebBrowserDocumentCompletedEventArgs e)
{
// Print the document now that it is fully loaded.
((WebBrowser)sender).Print();
// Dispose the WebBrowser now that the task is complete.
((WebBrowser)sender).Dispose();
}
}
我有这个代码用于打印HTML文件,会发生什么:
有些字母没有出现!包括特殊字符和非特殊字符......
示例:其中1页:“Agora pode consultar”,出现“Agora pode cons tar”
答案 0 :(得分:1)
您是否设置了编码,例如UTF-8?
webBrowserForPrinting.Document.Encoding = Encoding.GetEncoding("UTF-8");
和webBrowserForPrinting1
相同