Save complete page in htmlviewer as jpg

  1. 7 weeks ago

    Is it possible to save the page visible in the htmlviewer as an image to file? I mean the whole page, not just the visible part.

  2. Christian S

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

    Which platform? Mac, Windows, Linux or iOS?

  3. Christian S

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

    e.g. For MacOS with MBS Xojo Plugins and WebVIewMBS class:

    Dim webview As webviewMBS = HTMLViewer1.WebVIewMBS
    Dim i As NSImageMBS = webview.RenderWebsiteImage
    
    Dim p As String = i.JPEGRepresentation
    
    Dim f As FolderItem = SpecialFolder.Desktop.Child("test.JPG")
    
    Dim b As BinaryStream = BinaryStream.Create(f, True)
    b.Write p
  4. Jean-Yves P

    Jan 9 Pre-Release Testers, Xojo Pro Europe (France, Besançon)
    Edited 7 weeks ago

    htmlviewer.drawinto a graphic object , so use the graphics of a picture ?

  5. @Jean-YvesPochez htmlviewer.drawinto a graphic object , so use the graphics of a picture ?

    Nothing happen, nothing appears on the canvas.

    Var p As New Picture(htmlviewer1.Width, htmlviewer1.Height)
    htmlviewer1.DrawInto(p.Graphics, 0, 0)
    Canvas1.Backdrop = p
  6. Michel B

    Jan 9 Pre-Release Testers, Xojo Pro

    @Jean-YvesPochez htmlviewer.drawinto a graphic object , so use the graphics of a picture ?

    Unfortunately, DrawInto does not necessarily work. At least in Windows, it does not with HtmlViewer.

  7. Norman P

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

    from the command line with chrome or firefox
    works on macOS and windows

  8. Stephen P

    Jan 9 Pre-Release Testers, Xojo Pro

    @ChristianSchmitz Which platform? Mac, Windows, Linux or iOS?

    @ChristianSchmitz do you have a windows example ?

  9. @ChristianSchmitz e.g. For MacOS with MBS Xojo Plugins and WebVIewMBS class:

    Dim webview As webviewMBS = HTMLViewer1.WebVIewMBS Dim i As NSImageMBS = webview.RenderWebsiteImage Dim p As String = i.JPEGRepresentation Dim f As FolderItem = SpecialFolder.Desktop.Child("test.JPG") Dim b As BinaryStream = BinaryStream.Create(f, True) b.Write p

    Do you have a working example how to save the whole page as jpg for Windows and Mac/Linux?
    Same for saving just a specific part, like 1024x768 or 1280x720 etc.?
    I am looking for a crossplatform solution (Desktop, Windows, Mac, Linux).

  10. Christian S

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

    We do have IEImageMBS function on HTMLViewer control.
    You can use IEScrollHeightMBS and IEScrollWidthMBS to query size.
    With the size you can resize HTMLViewer to show whole page and then ask for the picture.

  11. @ChristianSchmitz We do have IEImageMBS function on HTMLViewer control.
    You can use IEScrollHeightMBS and IEScrollWidthMBS to query size.
    With the size you can resize HTMLViewer to show whole page and then ask for the picture.

    Does that work crossplatform or do I need for each platform another plugin?

  12. Christian S

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

    HTMLViewer is different on each platform!

  13. 6 weeks ago

    @ChristianSchmitz We do have IEImageMBS function on HTMLViewer control.
    You can use IEScrollHeightMBS and IEScrollWidthMBS to query size.
    With the size you can resize HTMLViewer to show whole page and then ask for the picture.

    I tried with IEImageMBS, but the picture created is too large.
    IEScrollHeightMBS return 3191, but the picture saved to file has a height of 4184, so it has lots of white at the end.

  14. Christian S

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

    Well, scroll height can be queried to resize the control to have the right size.
    As the image is based on the control size.

  15. I do that. The issue is HiDPI. I am running a 4K monitor with 150% scaling.
    When I disable HiDPI support in Xojo, its about right (Scrollbars are still there, even I resize the htmlviewer to the result of IEScrollHeightMBS).

  16. Norman P

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

    there are ways to get Firefox and chrome to do a snapshot of a page given a url
    completely headless and in the background

    see https://www.bleepingcomputer.com/news/software/chrome-and-firefox-can-take-screenshots-of-sites-from-the-command-line/

  17. Edited 6 weeks ago

    @Norman P there are ways to get Firefox and chrome to do a snapshot of a page given a url
    completely headless and in the background

    see https://www.bleepingcomputer.com/news/software/chrome-and-firefox-can-take-screenshots-of-sites-from-the-command-line/

    It only makes a screenshot 800x600, not the whole loaded page b default. And even you set a size, how do you know the size of the loaded page?

  18. Edited 6 weeks ago

    @ChristianSchmitz We do have IEImageMBS function on HTMLViewer control.
    You can use IEScrollHeightMBS and IEScrollWidthMBS to query size.
    With the size you can resize HTMLViewer to show whole page and then ask for the picture.

    Unfortunately, when setting the htmlviewer to native, it does not render all pages properly, and when I set it to WebKit, it renders all just fine, but IEScrollheightMBS return always 0.

    Note that this is just WIndow, no other target for now.

  19. Norman P

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

    @Guenter K It only makes a screenshot 800x600, not the whole loaded page b default. And even you set a size, how do you know the size of the loaded page?

    I've used this to make them whatever size I want (2560 x 1440) :)
    you can control the window size - there are hundreds of command line options for chrome (not quite so many for firefox)

  20. Newer ›

or Sign Up to reply!