CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Aug 1999
    Location
    Germany
    Posts
    2,338

    Webbrowser scale and print content

    Hi. In my application, I have a WebBrowser in which I load a webpage. This works fine, but now I want to scale the page (if the content is larger then my control) and then print the page (scaled, so that it fits to exactly one page).

    You can open the PrintDialog, but I want to do all this without user-interaction. Any ideas about that?
    Last edited by martho; February 6th, 2008 at 08:51 AM.

  2. #2
    Join Date
    Aug 2005
    Location
    Seattle, Wa
    Posts
    179

    Re: Webbrowser scale and print content

    Are you generating the HTML that is shown in the browser control?

    The job of the browser control is to display your HTML. If your HTML is wrapped in tables with fixed width <table width="600"> then its not going to scale. Using <table width="100%"> will scale to the size of the control.
    Images work the same way...

    Or perhaps you are trying to show a preview type display of the webpage?
    This may help: http://code.google.com/p/csexwb2/

  3. #3
    Join Date
    Aug 1999
    Location
    Germany
    Posts
    2,338

    Re: Webbrowser scale and print content

    Thanks for your reply. What I need is more like the zoom you find in IE7 at the right bottom, but done programmatically. This scales even images and pixel-layouts.

    Is this possible with the tool you mentioned?

  4. #4
    Join Date
    Mar 2007
    Posts
    375

    Re: Webbrowser scale and print content

    Cant you override the paint function of the web browser and use matrices to zoom?
    Please vote the posts you find usefull.

    ---

    I'm back
    Bigger and badder
    Better and bolder
    Explaining stuff -
    With an improved vocabulary!

  5. #5
    Join Date
    Aug 2000
    Location
    South East England
    Posts
    86

    Re: Webbrowser scale and print content

    I too have been trying to scale the WebBrowser display.
    I am still trying to work out the values, but the following will change the scale.

    I can only get this to display at one biger size.
    WebBrowserControl is the name of my WebBrowser control
    Code:
      Dim pvaIn As Variant
      Dim pvaOut As Variant
      pvaIn = Null
      pvaOut = Null
     Call WebBrowserControl.ExecWB(OLECMDID_OPTICAL_GETZOOMRANGE, OLECMDEXECOPT_DODEFAULT, pvaIn, pvaOut)
      'Call WebBrowserControl.ExecWB(OLECMDID_OPTICAL_ZOOM, OLECMDEXECOPT_DODEFAULT, pvaIn, pvaOut)
      
      MsgBox "pvaIn= " & pvaIn & vbCrLf + "pvaOut= " & pvaOut, , 1
      
      pvaIn = pvaOut '* 1
      pvaIn = 65536010
      
      Call WebBrowserControl.ExecWB(OLECMDID_OPTICAL_ZOOM, OLECMDEXECOPT_DODEFAULT, pvaIn, pvaOut)
      
      MsgBox "pvaIn= " & pvaIn & vbCrLf + "pvaOut= " & pvaOut, , 2
    Don't spend too much time on your computer.
    Sit on a chair instead!!
    It's a lot more comfortable and better for your hardware.

    :-/

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured