Dela via


PrintExtensionContext Class

Definition

Provides the context for the printer extension object.

public ref class PrintExtensionContext abstract sealed
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Devices.Printers.Extensions.ExtensionsContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
class PrintExtensionContext final
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Devices.Printers.Extensions.ExtensionsContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
public static class PrintExtensionContext
Public Class PrintExtensionContext
Inheritance
Object Platform::Object IInspectable PrintExtensionContext
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

The following JavaScript code snippet retrieves the PrinterExtensionContext using a DeviceInformation ID, and then uses the context to create a helper object:

// This function runs when the user taps the Back button
function getInkStatus(deviceInformationId) {
    var responseString;
    try {
        var context = Windows.Devices.Printers.Extensions.
            PrintExtensionContext.fromDeviceId(deviceInformationId);
        var helper = new Microsoft.Samples.Printing.WwaDca.
            PrintHelperClass(context);
        var responseString = helper.getInkLevel(1);
    } catch (e) {
        responseString = "deviceInformationId: " + deviceInformationId + 
            " Message: " + e.message;
    }
    return responseString
}

For more information about using the PrinterExtensionContext class, see the UWP device apps for printers topic on the Hardware Dev Center.

Methods

FromDeviceId(String)

Gets the context for the printer extension object based on the DeviceInformation ID.

Applies to

See also