PrepAway - Latest Free Exam Questions & Answers

Which code segments should you use?

You are developing a Windows Store app.
The app has the following requirements:
The app must print from the Devices charm.
In-app printing must be invoked by using a Print button on the user interface.
You need to ensure that the user can print documents successfully.
Which code segments should you use? (Each answer presents part of the solution. Choose all that
apply.)

PrepAway - Latest Free Exam Questions & Answers

A.
Option A

B.
Option B

C.
Option C

D.
Option D

Explanation:
B: ShowPrintUIAsync is an asynchronous method and it is responsible for making your Windows
Store app display the appropriate print window. Here is a JavaScript code snippet to show how it is
used to display a print window:
// Function to process the print button click
function printButtonClick() {
Windows.Graphics.Printing.PrintManager.showPrintUIAsync();
}
D: Example:
1. To each screen in your app from which you want to print, add the following code so that it runs
when the screen is opened. In the PrintSampleJS sample app, this is done in the ready member of
the members parameter to the WinJS.UI.Pages.define function that is called to create the screen.
JavaScript
var printManager = Windows.Graphics.Printing.PrintManager.getForCurrentView();
printManager.onprinttaskrequested = onPrintTaskRequested;
Add the print-task event handler for that screen. Each screen in your app might need a different
function if, for example, the content of each needs to be formatted differently for printing.
This PrintSampleJS app includes a completion handler, which is shown here. It’s a good idea to
handle completion events because then your app can let the user know if an error occurred and

provide possible solutions. Likewise, your app could use the completion event to indicate
subsequent steps for the user to take after the print job is successful.
JavaScript
function onPrintTaskRequested(printEvent) {
var printTask = printEvent.request.createPrintTask(“Print Sample”, function (args) {
args.setSource(MSApp.getHtmlPrintDocumentSource(document));
// Register the handler for print task completion event
printTask.oncompleted = onPrintTaskCompleted;
});
}
http://msdn.microsoft.com/enus/library/windows/apps/windows.graphics.printing.printmanager.showprintuiasync.aspx
http://msdn.microsoft.com/en-us/library/windows/apps/Hh780609.aspx


Leave a Reply