The basic algorithm is to programmatically instantiate an <iframe>, populate it with content, and then invoke its print method as illustrated below:
// create print frame
var pFrame = Ext.get('printerFrame');
if (!pFrame) {
Ext.getBody().insertHtml("beforeEnd","<iframe id='printerFrame' style='display:none'> </iframe>");
pFrame = Ext.get('printerFrame');
}
var contentWindow = pFrame.dom.contentWindow;
contentWindow.document.body.innerHTML = 'This is some html';
contentWindow.print();
Invoking the print() method launches the iOS printer chooser, enabling you to print to any AirPrint printer. This technique should also work for Ext JS 4.
No comments:
Post a Comment