wxHtmlWindow - Printing?
wxHtmlWindow - Printing?
I'm having trouble figuring out how to print a wxHtmlWindow called HtmlWindow1 in my application.
I've tried treating it like a file by creating an instance of wxHtmlEasyPrinting class and then accessing the PrintFile method with no success.
I just can't figure out how to print the Html widget in wxWidgets.
Any clues as to how this is done?
Thanks
I've tried treating it like a file by creating an instance of wxHtmlEasyPrinting class and then accessing the PrintFile method with no success.
I just can't figure out how to print the Html widget in wxWidgets.
Any clues as to how this is done?
Thanks
Re: wxHtmlWindow - Printing?
You can't print any widget directly. In this case, use wxHtmlEasyPrinting::PrintText() and pass the HTML code from from your wxHtmlWindow.
Use the source, Luke!
Re: wxHtmlWindow - Printing?
but what if I don't have html code? I'm trying to print the htmlwindow widget out with all it's contents?
I suppose I should be asking, how do you print a wxWidget?
I suppose I should be asking, how do you print a wxWidget?
Re: wxHtmlWindow - Printing?
If you have a wxHtmlWindow, you usually also have the html code (where else would it come from?)
If you were using wxWidgets 2.9.x, use wxWebView instead, which has a Print() method:
http://docs.wxwidgets.org/trunk/classwx_web_view.html
If you were using wxWidgets 2.9.x, use wxWebView instead, which has a Print() method:
http://docs.wxwidgets.org/trunk/classwx_web_view.html
Use the source, Luke!
Re: wxHtmlWindow - Printing?
I'm using the html window in a different way to normal. Lets's forget the world html It's a white page to me.
I've mounted some widgets to it and will be having those widgets display data in a report. So I basically have an html page in a GUI which contains some numbers and words. No html at all. I've done this because it can be printed like a page and displayed in a GUI. I want to print it. If all this is is 'Printing a Widget' then maybe this is what I should ask. Sorry, but I'm not overly experienced in this area but I'm getting there.
Should a start another thread asking how to print a widget? How do you print a widget?
I've mounted some widgets to it and will be having those widgets display data in a report. So I basically have an html page in a GUI which contains some numbers and words. No html at all. I've done this because it can be printed like a page and displayed in a GUI. I want to print it. If all this is is 'Printing a Widget' then maybe this is what I should ask. Sorry, but I'm not overly experienced in this area but I'm getting there.
Should a start another thread asking how to print a widget? How do you print a widget?
Re: wxHtmlWindow - Printing?
The answer will be the same: You can't.Should a start another thread asking how to print a widget? How do you print a widget?
If you want to have something printed, you must be able to draw it to a device context. wxWidgets uses native controls where ever possible. And e.g a button can't draw itself onto a printer device context.
In other words: Whatever screen you created using widgets (can you show a screenshot?), you will have to recreate it with wxDC drawing operations if you want to print it.
You could try to use wxClientDC or wxWindowDC to grab the content of a widget from the screen, but it would probably only work for widgets currently visible and i'm not sure it'll work on all platform. But i've never tried it.
Use the source, Luke!
Re: wxHtmlWindow - Printing?
doublemax is right, with the exception that the newer wxWebView will be able to print widgets (since it uses WebKit/Trident, but of which support printing everything)
"Keyboard not detected. Press F1 to continue"
-- Windows
-- Windows
Re: wxHtmlWindow - Printing?
Right, thanks.
It'll take time but I'm sure I'll figure something out eventually.
It'll take time but I'm sure I'll figure something out eventually.
- tierra
- Site Admin
- Posts: 1355
- Joined: Sun Aug 29, 2004 7:14 pm
- Location: Salt Lake City, Utah, USA
- Contact:
Re: wxHtmlWindow - Printing?
This approach also means you're just printing a bitmap from a screenshot. This can be highly inefficient and very restrictive.doublemax wrote:You could try to use wxClientDC or wxWindowDC to grab the content of a widget from the screen, but it would probably only work for widgets currently visible and i'm not sure it'll work on all platform. But i've never tried it.
For example, it doesn't scale to high DPI printers, and uses a massive amount of memory it has to transfer to the print job, which is bad for wireless printers.
Re: wxHtmlWindow - Printing?
Well thanks tierra, do you have another solution?
Re: wxHtmlWindow - Printing?
Can you show a screenshot of what you need to print? Even if you say you don't know html, the view things you need to know to use wxHtmlEasyPrinting can be learned in an hour or less.
Use the source, Luke!
- tierra
- Site Admin
- Posts: 1355
- Joined: Sun Aug 29, 2004 7:14 pm
- Location: Salt Lake City, Utah, USA
- Contact:
Re: wxHtmlWindow - Printing?
This has been mentioned a couple times already, but your best option, and the way to do this properly really is to fetch the HTML page from wxHtmlWindow, and pass it over to wxHtmlEasyPrinting.