Print​Task​Request Print​Task​Request Print​Task​Request Class

Definition

Contains the request from the system to create a print task. This object is available from the PrintTaskRequestedEventArgs object passed to the PrintTaskRequested event.

public : sealed class PrintTaskRequest : IPrintTaskRequestpublic sealed class PrintTaskRequest : IPrintTaskRequestPublic NotInheritable Class PrintTaskRequest Implements IPrintTaskRequest
Attributes
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)

Remarks

The PrintTaskRequest class is used by an app to create a new PrintTask object. A PrintTask object is created in response to the PrintTaskRequested event and it indicates to the system that the app has content to be printed. When creating a PrintTask object using the CreatePrintTask method, the app must provide a name for the PrintTask and a PrintTaskSourceRequestedHandler event handler which is called when the content to be printed is required.

An app should do the minimum amount of work possible in the PrintTaskRequested event handler since only a short amount of time is provided for a response. Wherever possible, the app should simply create a PrintTask and delay any content initialization until the PrintTaskSourceRequestedHandler event handler is called.

If an app needs to perform an asynchronous operation during the PrintTaskRequested handler it must retrieve and use a PrintTaskRequestedDeferral object. Prior to the exit of the event handler, and typically before the asynchronous operation is started, the app must retrieve the PrintTaskRequestedDeferral object by calling the GetDeferral method of the PrintTaskRequest object. When the asynchronous operation completes, the app must call the Complete method of the PrintTaskRequestedDeferral object to signal that the print task request is complete. The call to the Complete method must occur before the Deadline is reached in order for the request to be accepted.

The CreatePrintTask method in PrintTaskRequest can be used to create the print task. Here is a JavaScript code snippet showing the creation of a print task:

    // Print event handler for printing via the PrintManager API.
    // printEvent contains the print task request object
    function onPrintTaskRequested(printEvent) {
        printEvent.request.createPrintTask("Print Sample", function (args) {
            args.setSource(MSApp.getHtmlPrintDocumentSource(document));
        }); 
    }

For more information on this and other printing scenarios, see Printing on the Windows Dev Center.

Properties

Deadline Deadline Deadline

Gets a DateTime value that indicates how long an app has to respond to the PrintTaskRequested event. If the system has not received a response from the PrintTaskRequested event handler by the time the deadline is reached, then the print task is ignored.

public : DateTime Deadline { get; }public DateTimeOffset Deadline { get; }Public ReadOnly Property Deadline As DateTimeOffset
Value
DateTime DateTimeOffset DateTimeOffset

A value that indicates how long an app has to respond to the PrintTaskRequested event.

Attributes
See Also
DateTimeDateTimeOffsetDateTimeOffset

Methods

CreatePrintTask(String, PrintTaskSourceRequestedHandler) CreatePrintTask(String, PrintTaskSourceRequestedHandler) CreatePrintTask(String, PrintTaskSourceRequestedHandler)

Creates a new PrintTask which indicates that the app has content to be printed.

public : PrintTask CreatePrintTask(PlatForm::String title, PrintTaskSourceRequestedHandler handler)public PrintTask CreatePrintTask(String title, PrintTaskSourceRequestedHandler handler)Public Function CreatePrintTask(title As String, handler As PrintTaskSourceRequestedHandler) As PrintTask
Parameters
title
PlatForm::String String String

Title for the print task.

handler
PrintTaskSourceRequestedHandler PrintTaskSourceRequestedHandler PrintTaskSourceRequestedHandler

Pointer to a PrintTaskSourceRequestedHandler delegate for the print task.

Returns

Pointer to the print task that was created.

Attributes
See Also

GetDeferral() GetDeferral() GetDeferral()

Retrieves the deferral object associated with the PrintTaskRequest. The deferral object is used to handle asynchronous calls in the PrintTaskRequested event handler.

public : PrintTaskRequestedDeferral GetDeferral()public PrintTaskRequestedDeferral GetDeferral()Public Function GetDeferral() As PrintTaskRequestedDeferral
Returns

The PrintTaskRequestedDeferral for a print task.

Attributes

See Also