0
    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”

4

1 回答 1

1

您是否设置了编码,例如 UTF-8?

webBrowserForPrinting.Document.Encoding = Encoding.GetEncoding("UTF-8"); 

和 webBrowserForPrinting1 一样

于 2013-06-07T15:29:57.617 回答