HTML and CSS Reference
In-Depth Information
In general, you need to have code similar to the following in order to handle click events on print
buttons in your application.
printerApp.print1 = function () {
printerApp.preparePrint1();
Windows.Graphics.Printing.PrintManager.showPrintUIAsync();
}
printerApp.print2 = function () {
printerApp.preparePrint2();
Windows.Graphics.Printing.PrintManager.showPrintUIAsync();
}
The preparePrint1 and preparePrint2 methods are specular methods that just add printable data
to the document subtree and hide unneeded print templates. You define both in the printerApp.js file.
The print1 and print2 methods are invoked from the click handlers of the print buttons in the user
interface.
The showPrintUIAsync system method is responsible for programmatically displaying the Charms
bar for printing—the exact same panel that a user can pop up by swiping from the right edge of the
screen. Figure 12-12 shows the print preview when the second template is sent to printers.
FIGURE 12-12 Gaining control over the content being printed.
Overall, printing from within a WinJS application is a matter of editing the current page so that it
only sends out the content you want to print to the browser.
Search WWH ::




Custom Search