PrintTask PrintTask PrintTask PrintTask PrintTask Class


Represents a printing operation including the content to be printed, as well as providing access to information describing how the content is to be printed.

public : sealed class PrintTask
struct winrt::Windows::Graphics::Printing::PrintTask
public sealed class PrintTask
Public NotInheritable Class PrintTask
// This class does not provide a public constructor.

Windows 10 requirements

Device family
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)


The PrintTask object represents a printing operation for UWP apps. The app is responsible for creating a PrintTask that is requested via the PrintTaskRequested event on the PrintManager object. To create PrintTask you must provide the name for the task and a PrintTaskSourceRequestedHandler delegate which is called when the user is ready to begin printing.

If the user decides not to print the task, the task may be completed without ever requesting the document source.

PrintTask contains a reference, in the form of the Source property, to the Print Document Source provided by the app. This object must support the IPrintDocumentSource interface.

In addition PrintTask contains an Options property which holds a reference to the PrintTaskOptions object. The PrintTaskOptions object provides access to details about the desired format of the printed content. PrintTaskOptions also provides methods which allow aspects of the print user experience to be modified. For example, PrintTaskOptions allows the app to define which of the supported options appear on the initial page of the print experience.

A print task goes through a specific set of states after its creation, and these changes in state can be used by an app to provide feedback to the user. Most of the state transitions are represented in the events that are raised by PrintTask. The print task is created in response to the PrintTaskRequested event on the PrintManager using the CreatePrintTask method on the PrintTaskRequest object. At this point the print task cannot be printed, since the content to print has not yet been provided. Typically a PrintTaskRequested event is raised when the user clicks on the Devices charm or an application initiates printing via the ShowPrintUIAsync method on the PrintManager.

Once the system determines that the task will be printed, the PrintTaskSourceRequestedHandler delegate is called to actually retrieve a reference to the Document Source object. At this point PrintTask is fully initialized. If the user decides not to complete the printing represented by the PrintTask object, the completion event is raised with a completion type of abandoned.

Upon initialization the printing user experience is responsible for helping the user select the different attributes, such as paper size or duplex, for the printed content. When the print window initialization is almost complete, PrintTask raises the Previewing event. This is when the user is now able to manipulate the contents of the PrintTaskOptions object via the print window. The user may change the values of the settings at any time during the Preview stage, and this must be taken into consideration the next time an app paginates the content. The PrintTaskOptions object provides basic functionality for retrieving the values of the print settings. For more advanced control of the print options, see PrintTaskOptionDetails. Again the user may cancel this operation which will result in a completion event being raised with a completion type of cancelled.

When the user chooses to actually initiate printing by pressing Print in the print window, for example, the print task transitions from Previewing to the Submitting state, and the Submitting event is raised. The print document source is then passed a MakeDocument command and the process of submitting pages to the print subsystem begins. While pages are being submitted, the Progressing event is raised. An app may choose to use the information in the progressing event to let the user know how much content remains to be printed. Once the process of submitting the document to the print subsystem is complete, PrintTask raises the Completion event. This event indicates whether the job was submitted successfully, canceled, or failed during the submission process.

Here is a JavaScript code snippet that shows how to indicate the order in which the default print settings should be displayed:

    // Print event handler for printing via the PrintManager API.
    // printEvent contains the print task request object
    function onPrintTaskRequested(printEvent) {    
        var printTask = printEvent.request.createPrintTask("Print Sample", function (args) {

        // Enumerate the printer settings you want to show.
        // They appear in the print window in the same order
        // that you list them here

        //You may even preset the values on a printer setting
        printTask.options.mediaSize = Windows.Graphics.Printing.PrintMediaSize.northAmericaLegal;

To see the complete listing for this, and other printing scenarios using PrintTask, see Printing.

Version history

Windows version SDK version Value added
1607 14393 IsPreviewEnabled


Is3DManufacturingTargetEnabled Is3DManufacturingTargetEnabled Is3DManufacturingTargetEnabled Is3DManufacturingTargetEnabled Is3DManufacturingTargetEnabled

Gets or sets a value that indicates whether the PrintTask supports 3D manufacturing devices, like a 3D printer.

IsPreviewEnabled IsPreviewEnabled IsPreviewEnabled IsPreviewEnabled IsPreviewEnabled

Gets or sets a value that indicates whether the PrintTask will show a print preview.

IsPrinterTargetEnabled IsPrinterTargetEnabled IsPrinterTargetEnabled IsPrinterTargetEnabled IsPrinterTargetEnabled

Gets or sets a value indicating whether the PrintTask supports printer targets.

Options Options Options Options Options

Retrieves the PrintTaskOptions for the print task that defines how the content is to be formatted for printing.

Properties Properties Properties Properties Properties

Retrieves a set of properties associated with the PrintTask.

Source Source Source Source Source

Returns a pointer to the app-provided object that represents the content to be printed. This object must support the IPrintDocumentSource interface.


Completed Completed Completed Completed Completed

Raised when the print task is completed.

Previewing Previewing Previewing Previewing Previewing

Raised when the print system initializes print preview mode.

Progressing Progressing Progressing Progressing Progressing

Raised to provide progress information about how much of the printed content has been submitted to the print subsystem for printing.

Submitting Submitting Submitting Submitting Submitting

Raised when a print task begins submitting content to the print subsystem to be printed.

See also