-
22 Feb 2012 6:13 AM #1
Unanswered: How to make a print Button?
Unanswered: How to make a print Button?
I want to make a print button to print values of fields on a page.

-
23 Feb 2012 8:25 AM #2
To my knowledge, there is no simple way...
And it depends on what you want to print.
I think there is a way for JavaScript to request to the browser to print out the current page. This is probably not what you want.
Another way is to create on the server side a document laying out the information you need to print. It might be a simple HTML file, and maybe you can display it in a popup window and ask the browser to print it out. It can be problematic with popup blockers... Or it might be a PDF file made with iText, for example, and then the users can download it and print it themselves.
-
24 Feb 2012 9:12 AM #3
Here's what I did for starters:
I think this executes javascript:print() and prints the browser window. The Images class is simply my image provider class.Code:TextButton printButton = new TextButton("Print", Images.INSTANCE.print()); printButton.addSelectHandler(new SelectHandler() { @Override public void onSelect(SelectEvent event) { Window.print(); } });
I think Philho is right though, if you want a formatted page to be printed, you'll need to format the data you want to print, slap that in some type of pop-up window and then call Window.print inside that pop-up window.
HTH.
--adam
-
28 Feb 2012 2:55 AM #4
OK thank you.
I'v done it


Reply With Quote