Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Printing a web page

Printing a web page

Scheduled Pinned Locked Moved C#
html
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    draco_iii
    wrote on last edited by
    #1

    I am looking for a way to print and html page from an embeded web browser window. Is there an easy way to do this. I created the document because I did not want to go through all the trouble of designing my own print function to do every line and all the text on the page.

    H M 2 Replies Last reply
    0
    • D draco_iii

      I am looking for a way to print and html page from an embeded web browser window. Is there an easy way to do this. I created the document because I did not want to go through all the trouble of designing my own print function to do every line and all the text on the page.

      H Offline
      H Offline
      Heath Stewart
      wrote on last edited by
      #2

      Call AxWebBrowser.ExecWB with OLECMDID.OLECMDID_PRINT, and with the OLECMDEXECOPT enumeration you want (like OLECMDEXECOPT.OLECMDEXECOPT_PROMPT to show the print UI). If you read the documentation for the IDM_PRINT[^] (works the same as OLECMDID_PRINT), you can see what you can pass for the pvaIn and pvaOut params. For instance, to just print the page using the default printer without showing the UI, you could do the following:

      object pvaIn = 1; // PRINT_DONTBOTHERUSER
      object pvaOut = null;
      axWebBrowser1.ExecWB(OLECMDID.OLECMDID_PRINT,
      OLECMDEXECOPT.OLECMDEXECOPT_DONTPROMPTUSER, ref pvaIn, ref pvaOut);

      Executing commands on the AxWebBrowser control (from creating an ActiveX interop assembly on the shdocvw.dll library, as is common) is the same as getting the IOleCommandTarget, which does the same functionality as using the various commands from the Internet Explorer (iexplore.exe) application. So, if you passed parameters to prompt the user to pick a printer and change other options, it would be the same as File-<Print in Internet Explorer.

      Microsoft MVP, Visual C# My Articles

      1 Reply Last reply
      0
      • D draco_iii

        I am looking for a way to print and html page from an embeded web browser window. Is there an easy way to do this. I created the document because I did not want to go through all the trouble of designing my own print function to do every line and all the text on the page.

        M Offline
        M Offline
        Michael Flanakin
        wrote on last edited by
        #3

        You should be able to just use javascript: window.print(); Michael Flanakin Web Log

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups