使用Google Chrome进行C#静态打印

时间:2015-11-20 15:57:00

标签: c# google-chrome

我一直在寻找是否可以通过C#app制作谷歌浏览器来打印特定的HTML文档。不幸的是,我没有找到答案。那么,有没有办法用GC打印html文档但不能用IE打印?附:谢谢你的回答

namespace testPritn
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();


        }

        private void PrintHelpPage()
        {
            // Create a WebBrowser instance. 
            WebBrowser webBrowserForPrinting = new WebBrowser();

            // Add an event handler that prints the document after it loads.
            webBrowserForPrinting.DocumentCompleted +=
                new WebBrowserDocumentCompletedEventHandler(PrintDocument);

            // Set the Url property to load the document.
            webBrowserForPrinting.Url = new Uri(@"D:\test.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();
        }
        private void button1_Click(object sender, EventArgs e)
        {
            PrintHelpPage();
        }
    }
}

0 个答案:

没有答案