Print html document from Windows Service without print dialog

后端 未结 5 974
青春惊慌失措
青春惊慌失措 2020-11-30 05:53

I am using a windows service and i want to print a .html page when the service will start. I am using this code and it\'s printing well. But a print dialog box come, how do

5条回答
  •  没有蜡笔的小新
    2020-11-30 06:36

    From this site http://www.ussbd.com/printhtm.html

    using HtmlPrinter;
    hpObj=new HtmlPrinter.HtmlPrinter();
    hpObj.PrintUrlFromMemory(txtUrl.Text);
    

    Now you add the code in your project to print html page from its source text:

    HtmlPrinter.HtmlPrinter hpObj=new HtmlPrinter.HtmlPrinter();
    hpObj.PrintHtml(txtString.Text, true);
    

    If you want to print without the print dialog then use the following line:

    hpObj.PrintHtml(txtString.Text, false); 
    

提交回复
热议问题