PrintManager Class

Definition

Provides the entry-point for printing within an application.

public ref class PrintManager sealed
class PrintManager sealed
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Muse(Version=100794368)]
[Windows.Foundation.Metadata.Static(typeof(Windows.Graphics.Printing.IPrintManagerStatic), 65536, typeof(Windows.Foundation.UniversalApiContract))]
public sealed class PrintManager
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Muse(Version=100794368)]
[Windows.Foundation.Metadata.Static(typeof(Windows.Graphics.Printing.IPrintManagerStatic), 65536, "Windows.Foundation.UniversalApiContract")]
public sealed class PrintManager
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Muse(Version=100794368)]
[Windows.Foundation.Metadata.Static(typeof(Windows.Graphics.Printing.IPrintManagerStatic), 65536, "Windows.Foundation.UniversalApiContract")]
[Windows.Foundation.Metadata.Static(typeof(Windows.Graphics.Printing.IPrintManagerStatic2), 196608, "Windows.Foundation.UniversalApiContract")]
public sealed class PrintManager
Public NotInheritable Class PrintManager
Inheritance
PrintManager
Attributes

Windows 10 requirements

Device family
Windows 10 (introduced in 10.0.10240.0 - for Xbox, see UWP features that aren't yet supported on Xbox)
API contract
Windows.Foundation.UniversalApiContract (introduced in v1.0)

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 when the application invokes the printing dialog via the ShowPrintUIAsync method.

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:

    var app = WinJS.Application;

    // This function responds to all application activations.
    app.onactivated = function (eventObject) {
        if (eventObject.detail.kind === Windows.ApplicationModel.Activation.ActivationKind.launch) {
           
            //Register for print contract
            var printManager = Windows.Graphics.Printing.PrintManager.getForCurrentView();
            printManager.onprinttaskrequested = onPrintTaskRequested;
        
            WinJS.UI.processAll();
        }
    };

For more examples involving the print manager and to see some sample code for printing scenarios in UWP apps, see Printing in the Windows Dev Center.

Version history

Windows version SDK version Value added
1607 14393 IsSupported

Methods

GetForCurrentView()

Retrieves the PrintManager object associated with the current window.

IsSupported()

Indicates whether or not the app is running on a device that supports printing.

ShowPrintUIAsync()

Programmatically initiates the user interface for printing content.

Events

PrintTaskRequested

Raised when a request to print has occurred. This event may be triggered by user action or via programmatic invocation of printing via the ShowPrintUIAsync method.

Applies to

See also