Save complete page in htmlviewer as jpg

  1. ‹ Older
  2. 6 weeks ago

    Norman P

    Jan 14 Pre-Release Testers, Xojo Pro outside listening to the crick...

    1) you dont - there is no intrinsic height or width for a web page - so you tell chrome how big you want the image and it does its thing. you can control the size of the layout that it takes a picture of but again there is no way to know ahead of time (just like if you open a browser window it opens at whatever size the browser opens it NOT at whatever size the web page says it should be)

    2) it does - or firefox - either works
    I have not checked opera as well but between chrome, ff, opera and IE you probably handle most browsers

    the app I'm working on also has tried to use webkit and IE with and without MBS and had mixed results

  3. I can get the height fine with Delphi and TWebBrowser, using IHTMLElement2 and the scrollheight property of it, and the image is always the whole page. I set the browser to that height, the moment it has to create the image, then I create the image and its a 100% match. And thats what I try to replicate with Xojo, NOT using external browser which might not be installed on the clients PC.
    If thats not possible, its also ok.

  4. Christian S

    Jan 14 Pre-Release Testers, Xojo Pro, XDC Speakers, Third Party Store Germany

    I check the sample example and it works fine here, with 150% or 300% DPI no problem.
    You can send me an email to get the new example.

    Code is like this:

    // resize web viewer to show full website without scrolling
    
    Dim doc As IEDocumentMBS = web.IEDocumentMBS
    
    If doc <> Nil Then
      
      Dim w As Integer = web.Width
      Dim h As Integer = web.Height
      
      web.Width  = doc.ScrollWidth + 24
      web.Height = doc.ScrollHeight + 24
      
      // now get picture
      pic = doc.Image
      
      // restore size
      web.Width  = w
      web.Height = h
      
      out.Invalidate
      
    Else
      MsgBox "No website loaded?"
    End If

    So we resize htmlviewer to avoid scrollbars and then render image.

  5. @ChristianSchmitz The more serious problem is, that the htmlviewer does not render pages properly. On some pages, images are just not there, or the whole layout is not right, so I wont be able to use htmlviewer with native browser selected. The pages are looking correct when using Webkit, but then the IExxx of your plugin wont work. So I am running in circles somehow.

  6. Christian S

    Jan 14 Pre-Release Testers, Xojo Pro, XDC Speakers, Third Party Store Germany

    Sorry to hear. You can try e.g. Xojo 2019r1 with our ChromiumBrowserMBS class to render an image there.

  7. Norman P

    Jan 14 Pre-Release Testers, Xojo Pro outside listening to the crick...

    @Guenter K I can get the height fine with Delphi and TWebBrowser

    Sure but Xojo is not delphi so ........

  8. 5 weeks ago

    When htmlviewer use the IE engine, why cant it render pages correct, but IE can (or other IE based browser or wrapper)?

  9. @Guenter K When htmlviewer use the IE engine, why cant it render pages correct, but IE can (or other IE based browser or wrapper)?

    Can anybody answer this?

  10. Michel B

    Jan 19 Pre-Release Testers, Xojo Pro

    @Guenter K When htmlviewer use the IE engine, why cant it render pages correct, but IE can (or other IE based browser or wrapper)?

    https://blog.xojo.com/2016/01/04/use-newer-version-of-internet-explorer-with-webbrowser-and-htmlviewer/

  11. @Michel B https://blog.xojo.com/2016/01/04/use-newer-version-of-internet-explorer-with-webbrowser-and-htmlviewer/

    Doesn't help, I already did that, makes no difference.

  12. Michael D

    Jan 19 Pre-Release Testers, Xojo Pro

    @Guenter K makes no difference.

    There's a dramatic difference between the default IE 7 rendering engine and IE 11 - so if nothing changed, then you aren't doing it correctly.

    Can you show us your sample code for setting the registry items?

  13. Christian S

    Jan 19 Pre-Release Testers, Xojo Pro, XDC Speakers, Third Party Store Germany

    with latest MBS Plugins, you can use this code:

    // make sure we don't end up with Internet Explorer in version 7, which is default.
    Dim v As Integer = IEWebBrowserMBS.GetInternetExplorerVersion
    
    If v < 11000 Then // below version 11.0
      
      Dim b As Boolean = IEWebBrowserMBS.SetInternetExplorerVersion(11000) 
      If b Then
        MsgBox "Requested Internet Explorer version 11.0."
      Else
        MsgBox "Failed to set IE version?"
      End If
    End If

    We added IEWebBrowserMBS .SetInternetExplorerVersion to help with our new Evaluate function to work properly.

  14. @Michael D There's a dramatic difference between the default IE 7 rendering engine and IE 11 - so if nothing changed, then you aren't doing it correctly.

    Can you show us your sample code for setting the registry items?

    There is nothing to show, I have set them "by hand", not by code.
    The .exe is test.exe, I set a key/value in HKCU/SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION with a name of test.exe and a DWORD value of 11000 (I also tried 11001). I rebooted to be sure, and nothing changed in htmlviewer, page still wont get rendered properly.

  15. Emile S

    Jan 20 Europe (France, Strasbourg)

    I am quite sure you know, but:

    https://en.wikipedia.org/wiki/Internet_Explorer#End_of_life

    That makes Edge 5 y/o by tomorrow ! ;)

  16. Christian S

    Jan 20 Pre-Release Testers, Xojo Pro, XDC Speakers, Third Party Store Germany

    Still IE ActiveX component is widely used for embedded browser, so this may be there for next ten years.

  17. @Emile S I am quite sure you know, but:

    https://en.wikipedia.org/wiki/Internet_Explorer#End_of_life

    That makes Edge 5 y/o by tomorrow ! ;)

    Yes, but there is currently no other way than to use IE, if you want to make a full page screenshot, not just the visible area. I could never get that to work with Chromium (or Webkit in Xojo).

  18. Emile S

    Jan 20 Europe (France, Strasbourg)

    So, you will ask your users to use IE ?

  19. Michael D

    Jan 20 Pre-Release Testers, Xojo Pro
    Edited 5 weeks ago

    @Guenter K There is nothing to show, I have set them "by hand", not by code.

    As a test, point your HTMLViewer at this page https://www.whatismybrowser.com/detect/what-is-my-user-agent and see what the userAgent string says.

    With the IE7 renderer under Windows 10 it shows something like this:

    Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 10.0; WOW64; Trident/7.0; .NET4.0C; .NET4.0E)

    With the IE11 renderer under Windows 10 it shows something like this:

    Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko
  20. Tim S

    Jan 20 Pre-Release Testers Canterbury, UK
    Edited 5 weeks ago

    @Guenter K Doesn't help, I already did that, makes no difference.

    You need also to add this in your HTML page:

    <meta http-equiv="X-UA-Compatible" content="IE=11">

    And also use HTML5 DOCTYPE at the start of the document:

    <!DOCTYPE html>

    Then not only will the IE-11 renderer be loaded, but it will render as IE-11 and not IE-7.

    It took me a lot of time experimenting and web-searches to discover that this is necessary, which is why I asked for it to be added to the HTMLviewer docs.

    The registry changes make the IE-11 renderer load. The addition here makes it work properly.

  21. @Tim S You need also to add this in your HTML page:

    And also use HTML5 DOCTYPE at the start of the document:

    Then not only will the IE-11 renderer be loaded, but it will render as IE-11 and not IE-7.

    It took me a lot of time experimenting and web-searches to discover that this is necessary, which is why I asked for it to be added to the HTMLviewer docs.

    The registry changes make the IE-11 renderer load. The addition here makes it work properly.

    The page ist not my page, so how shall I change the code in it? Anyway, I will give up with this for now.

or Sign Up to reply!