Windows 10 (introduced v10.0.10240.0 - for Xbox, see UWP features that aren't yet supported on Xbox)

API contract

Windows.Foundation.UniversalApiContract (introduced v1)

Remarks

The PrintManager class is responsible for orchestrating the printing flow for UWP app. To use this class, you must first call the GetForCurrentView method. This method returns the PrintManager object that is specific to the current active window. Next, you must add an event listener for the PrintTaskRequested event. This event is raised by the system when a user indicates the possibility of initiating a printing operation. Typically this occurs when the user taps the Devices charm, but the event may also be invoked programmatically.

When a UWP app registers its "intention" to print, it creates a print contract with the print manager. Here is a JavaScript code snippet to show how to register your app for a print contract using a PrintManager:

A Boolean value to indicate a TRUE for success or a FALSE for a failure.

Remarks

This method may be used by an application which has already used GetForCurrentView to retrieve the PrintManager instance and has registered a listener for the PrintTaskRequested event to initiate the printing user experience. In general, applications are encouraged to let users print content via the Devices charm. For this reason, using the ShowPrintUIAsync method is discouraged. ShowPrintUIAsync is provided mainly for scenarios in which the app is to provide guidance for users to help users complete a printing-related process. For example, guidance at the end of a ticket purchasing process, or after checking in for a flight, and then printing a boarding pass.

ShowPrintUIAsync displays the appropriate printing window. If printing can't be performed at that time, the method will throw an exception. We recommend catching these exceptions and letting the user know when printing can't proceed, as shown here.

In this example, a print window is displayed in the event handler for a button click. If the method throws an exception (because printing can't be performed at that time), a ContentDialog control informs the user of the situation. For more info about printing from your app, see Printing.