Delen via


PrintTaskConfiguration Class

Definition

Allows a client to retrieve the print task extension context, and also to add an event handler to the print task.

public ref class PrintTaskConfiguration sealed
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Devices.Printers.Extensions.ExtensionsContract, 65536)]
class PrintTaskConfiguration final
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Devices.Printers.Extensions.ExtensionsContract), 65536)]
public sealed class PrintTaskConfiguration
Public NotInheritable Class PrintTaskConfiguration
Inheritance
Object Platform::Object IInspectable PrintTaskConfiguration
Attributes

Windows requirements

Device family
Windows Desktop Extension SDK (introduced in 10.0.10240.0)
API contract
Windows.Devices.Printers.Extensions.ExtensionsContract (introduced in v1.0)

Remarks

When a UWP app is invoked from More settings in the print window, the activation event provides an event argument of type Windows.UI.WebUI.WebUIPrintTaskSettingsActivatedEventArgs that exposes a property, Configuration, for controlling the printer. This property provides an object of type PrintTaskConfiguration that provides access to the print task extension context, and also allows you to add an event handler to update the print ticket.

The following JavaScript code snippet demonstrates how to access the PrintTaskConfiguration object, and then use that to access the PrinterExtensionContext property.

var configuration;
var printerExtesionContext;

function displayPrintSettings() {

    if (!configuration) {
        sdkSample.displayError("Configuration argument is null");
        return;
    }

    printerExtesionContext = configuration.printerExtensionContext;
    printHelper = new Microsoft.Samples.Printing.WwaDca.
        PrintHelperClass(printerExtensionContext);    

    var feature = "PageOrientation";

    // if printer's capabilities include this feature.
    if (!printHelper.featureExists(feature)) {
        continue;
    }

    // Get the selected option for this feature in the current
    // context's print ticket.
    var selectedOption = printHelper.getSelectedOptionIndex(feature);

    // Get the array of options in the current context’s print ticket
    var optionIndex = printHelper.getOptionInfo(feature, "Index"),
    var optionNames = printHelper.getOptionInfo(feature, 
        "DisplayName"),

    var selectedName;
    for (var i = 0; i < optionIndex.length; i++) {
        if (optionIndex[i] === selectedOption)
           selectedName = optionNames[i];

    // logic to display the orientation string here
}

Properties

PrinterExtensionContext

Gets the context for the print task extension.

Events

SaveRequested

Raised by the print window for your app to notify the device app that the print ticket must be updated.

Applies to

See also