How to print WebView contents?

edited February 2012 in Enyo 1.0
I have a WebView kind. How can I use the "printFrame" method of WebView to print the WebView contents?

printFrame(inName, inJobId, inWidth, inHeight, inDpi, inLandscape, inReverseOrder)



  • Look at the code for the web browser -- it's in the webOS SDK as SDK\share\applications\enyo\ It's use is a little complex, as you need to show a print dialog first to get the parameters.

  • edited February 2012
    Okay, just to close the loop. This is how I was able to successfully get my application (TouchTax) to print the contents of a Webview:

    Here's my Webview:
    {kind: "Scroller", name: "webScroller", flex: 1, components: [
    	{kind: enyo.WebView, name: "currentWebView", flex: 1, onPageTitleChanged: "actionPageChange", onLoadComplete: "actionHideWebViewSpinner", onLoadStarted: "actionShowWebViewSpinner"}
    Here's my PrintDialog Component:
    {name: "printDialog", kind: "PrintDialog",
    	lazy: false,
    	colorOption: true,
    	duplexOption: true,
    	onRenderDocument: "renderDocument",
            appName : "TouchTax"
    Here's my print button:
    {icon: "images/icn-print.png", name: "printButton", onclick: "printClick", className: "enyo-radiobutton-dark enyo-grouped-toolbutton-dark", style: "padding:0px; margin:0px; margin-left: 12px"},
    And finally, here's my printClick() function, together with the necessary renderDocument function referred to in the PrintDialog:
    printClick: function() {
    renderDocument: function(inSender, inJobID, inPrintParams) {
    	this.$.currentWebView.printFrame("", inJobID, inPrintParams.width, inPrintParams.height, inPrintParams.pixelUnits, false, inPrintParams.renderInReverseOrder);		
    Good luck with your programming.
Sign In or Register to comment.