HTMLviewer image to canvas question.

Would someone be willing to take a look at this small project and see if they can figure out why it bombs?

The idea is to have a window with just an HTMLVIEWER that would download a Webpage, snap a picture and return the image
I need to have this done invisible to the user (so ultimately I would move the one window in the project off screen entirely)

Everything works… EXCEPT when I try to programmatically close the Snapshot window… the program bombs…
If I comment out the self.close line, it works, but I have to manually close the window (which I do not want)

link text

OSX

I created a small project that uses HTMLViewer.Drawinto to place the picture of the HTMLVIewer into a canvas backdrop and it worked fine on Mac. Once on Windows, it did not work anymore. Windows simply does not drawinto anything from an HTMLViewer, would it be of the control itself, or the window on which it is.

I just created a bug report about that : 33637

[quote=87859:@Dave S]Would someone be willing to take a look at this small project and see if they can figure out why it bombs?

The idea is to have a window with just an HTMLVIEWER that would download a Webpage, snap a picture and return the image
I need to have this done invisible to the user (so ultimately I would move the one window in the project off screen entirely)

Everything works… EXCEPT when I try to programmatically close the Snapshot window… the program bombs…
If I comment out the self.close line, it works, but I have to manually close the window (which I do not want)

link text

OSX[/quote]

when i run the project i see a window with the ‘take a snapshot’ button and when i click on it… it just bomb and close the app and the come out with the scary error ‘problem report for my application.debug’’

[quote=87859:@Dave S]Would someone be willing to take a look at this small project and see if they can figure out why it bombs?

The idea is to have a window with just an HTMLVIEWER that would download a Webpage, snap a picture and return the image
I need to have this done invisible to the user (so ultimately I would move the one window in the project off screen entirely)

Everything works… EXCEPT when I try to programmatically close the Snapshot window… the program bombs…
If I comment out the self.close line, it works, but I have to manually close the window (which I do not want)

link text

OSX[/quote]

I’ll take a look shortly… :slight_smile:

[quote=90448:@Michel Bujardet]I created a small project that uses HTMLViewer.Drawinto to place the picture of the HTMLVIewer into a canvas backdrop and it worked fine on Mac. Once on Windows, it did not work anymore. Windows simply does not drawinto anything from an HTMLViewer, would it be of the control itself, or the window on which it is.

I just created a bug report about that : 33637[/quote]

Unfortunately Windows cannot drawinto from the htmlviewer (it could though…has been reported for quite some time :-/)
http://forums.realsoftware.com/viewtopic.php?f=1&t=43288

[quote=90529:@Matthew Combatti]Unfortunately Windows cannot drawinto from the htmlviewer (it could though…has been reported for quite some time :-/)
http://forums.realsoftware.com/viewtopic.php?f=1&t=43288[/quote]

The LR purports it does. Then if it does not work, it is a bug, and should be reported as such, even if workarounds exists.

And worse yet, the Mac HTMLViewer is exhibiting the same glitch.

Either DrawInto works as described in the LR, or the feature should be fixed. Or maybe Xojo engineers are less competent than users who simply applied API calls ?

Definitely should be looked into. The first feedback about it reports back to 2008.

Hi Matthew Combatti,

Finally I found the solution I need in my Desktop application.
ControlSnapShot

I have tested it and I saw it working very well expect one thing.
May I make a question?

I use lots of HTMLViewer(Webkit) for drawing JavaScript Charts.
I found out that if HTMLViewer is running with ‘Webkit’ mode, your ControlSnapShot doesn’t snap anything.

Attached simple test project.
link text

Can you let me know if it is expected behavior?

Hmm… somehow i don’t get it :wink:

Did you guys try MBS plugins for this?
There we have various methods to get image from htnlviewer.
For Mac, Win and Linux.

Hi Christian
Just resurrecting this thread,
I’m a subscriber to MBS and was wondering…

is it possible using MBS to take a snapshot of a WebHTMLViewer into a jpg or pdf?
what ever is simpler?

i.e. have a site up and snap it.
The use is Facebook ad previews. It seems impossible to grab the preview image
so I was wondering if I can simply snap the viewer?
Thanks Christian
Regards James

Well, check MBS Plugin methods for HTMLViewer:

  • Mac: RenderDocumentToPDFMBS, RenderPDFMBS and RenderWebsiteImageMBS
  • Win IE: IEImageMBS
  • Win WebKit: ChromiumBrowserMBS Image function

I’m sorry but I’m talking webhtmlviewer in a Linux web app

Oh, sorry. For WebHTMLViewer you would need to do that in Javascript and our plugin can’t help there.

Oh well - back to the drawing board

You’re going to have a lot of trouble trying to accomplish an image snapshot with WebHTMLViewer. Webpages generally don’t have access to the content of iframes to prevent malicious use.

IIRC Facebook ad previews are text/css, so if they still are you could copy the styling and generate your own.
(guess who doesn’t have facebook! ¯\(?)/¯ )

The drawing board is looking distinctively harder :frowning:

Might have to create a desktop mini app
Thanks for the heads up