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 に答える