Windows - save htmlviewer contents as image

Hi there - I have a an app that runs on both windows and Mac… however, while I can save the HTMLViewer contents as an image on the Mac using MBS plugins,
I’m wondering how to do this on windows.

Any ideas?

I did search the forum but it only had Mac examples.

Using MBSPlugins generally works on mac, however be aware that some content within a HTMLViewer may not render when you do this (examples include Flash plugins, WebGL animations, some videos, etc.)

For that reason, I changed over to actually taking a screenshot (also using MBSPlugins) of the window that’s displaying the HTMLViewer. The screenshot works for all content on both mac and windows. Limitations of a screenshot: the window has to be onscreen, you are limited to the maximum screen height, etc.

The MBS stuff works great on Mac. I.e.

[code] dim f as FolderItem
dim b as BinaryStream
dim i as NSImageMBS
dim p as string
dim pp as Picture



f= specialfolder.SharedApplicationData.child(“Guitar SightReader Toolbox”).child(“ABC”).child(“Tests”).child(“Printout.png”)
b.Write p[/code]

Windows is a different matter though.
I tried htmlviewer.print on windows - horrendous results (My SVGs were almost unrecognizable).

My html viewer window actually goes off the screen and needs to scroll (it’s music manuscript).

Is there a way to do this - render it into an image?

If your app is in charge of the HTML content, then you don’t have to worry about strange content not rendering, so I would use RenderWebsiteImageMBS on macOS.

I’ve never used .print on windows, but there have been lots of threads here about printing resolution issues - what Xojo version are you using?

We do have an HTMLViewer.IEImageMBS function.

I had a go with this… your example:

[code]Dim picWeb As Picture

// Get image from IE
picWeb = HTMLViewer1.IEImageMBS

canvas1.backdrop = picWeb[/code]

my code:

Dim picWeb As Picture picWeb = SRBrowser.IEImageMBS dim f as FolderItem f= specialfolder.ApplicationData.child("Guitar SightReader Toolbox").child("ABC").child("Tests").child("Printout.png") picweb.Save(f, picweb.SaveAsPNG)

this gave me an unsupportedOperationexception on this
picWeb = SRBrowser.IEImageMBS
SRBrowser is an Htmlviewer
what gives?


What’s the text of the exception?

picWeb = SRBrowser.IEImageMBS

When you get an exception in debugger, you can inspect the message property to learn more about the reason of the exception.