Advertisement
Java_Volume1 Internet/ HTML #93174

Print HTML from Visual Basic

The purpose of this article is to explain how to get the WebBrowser to print (i.e. there is no standard print method)

AI

AI 요약: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

소스 코드
original-source
<p>I was creating a form to be printed by HTML, then, after creating the form, realised that I didn’t know how to print the HTML. I looked into it further and found some obscure way in MSDN and some message boards to set focus (through Windows API) to my HTML WebBrowser control and send it a Control P key. The problem is that that only brings up a print dialogue. I didn’t even want to show the HTML form, let alone ask the user to select which printer. I searched further and found a workable solution. Here it is:</p>
<p></p>
<p></p>
<p>frmHTML.WebBrowser1.Navigate(&quot;C:\temp\Request.htm&quot;)</p>
<p>frmHTML.WebBrowser1.ExecWB OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER, 0, 0</p>
원본 댓글 (3)
Wayback Machine에서 복구됨