"<" + element.getTagName() + ">" + element.getInnerHTML() + "</" + element.getTagName() + ">"
On Monday, January 15, 2007 6:35:55 PM UTC+4, Freller wrote:
-- Other way it won't work after compilation.
On Monday, January 15, 2007 6:35:55 PM UTC+4, Freller wrote:
Following the thread about printing at
http://groups-beta.google.com/group/Google-Web-Toolkit/ browse_frm/thread/ 53624cb05aa85624/ 247e890d73a76948?lnk=gst&q= print&rnum=2#247e890d73a76948
I created a simple class that can print any HTML, DOM.Element or Widget without opening a new window.
Regards,
Freller
/**
* <pre>
* Generic printing class
* can be used to print the Window it self, DOM.Elements, UIObjects (Widgets) and plain HTML
*
* Usage:
* You must insert this iframe in your host page:
* <iframe id="__printingFrame" style="width:0;height:0;border:0"></iframe>
*
* Window:
* Print.it();
*
* Objects/HTML:
* Print.it(RootPanel.get("myId"));
* Print.it(DOM.getElementById("myId"));
* Print.it("Just <b>Print.it()</b>!");
*
* Objects/HTML using styles:
* Print.it("<link rel='StyleSheet' type='text/css' media='paper' href='/paperStyle.css'>", RootPanel.get('myId'));
* Print.it("<style type='text/css' media='paper'> .newPage { page-break-after: always; } </style>",
*"Hi<p class='newPage'></p>By");
* </pre>
*/
package org.gwtcommons.user.client;
import com.google.gwt.user.client.Element;
import com.google.gwt.user.client.ui.UIObject;
public class Print {
public static native void it() /*-{
$wnd.print();
}-*/;
public static native void it(String html) /*-{
var frame = $doc.getElementById('__printingFrame');
if (!frame) {
$wnd.alert("Error: Can't find printing frame.");
return;
}
frame = frame.contentWindow;
var doc = frame.document;
doc.open();
doc.write(html);
doc.close();
frame.focus();
frame.print();
}-*/;
public static void it(UIObject obj) {
it("", obj.getElement().toString());
}
public static void it(Element element) {
it("", element.toString());
}
public static void it(String style, String it) {
it("<it><header>"+style+"</header><body>"+it+"</body></ it>");
}
public static void it(String style, UIObject obj) {
it(style, obj.getElement().toString());
}
public static void it(String style, Element element) {
it(style, element.toString ());
}
} // end of class Print
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
No comments:
Post a Comment