» Fig Leaf Software Home

We've Got You Covered.

Friday, February 1, 2013

Printing from Sencha Touch and Ext JS 4

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

About Us

Fig Leaf Software is an award-winning team of imaginative designers, innovative developers, experienced instructors, and insightful strategists.

For over 20 years, we’ve helped a diverse range of clients...

Read More

Contact Us

202-797-7711

Fig Leaf Software

1400 16th Street NW
Suite 450
Washington, DC 20036

info@figleaf.com