PrintTaskConfiguration 類別

定義

可讓用戶端擷取列印工作延伸內容,以及將事件處理常式新增至列印工作。

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
繼承
Object Platform::Object IInspectable PrintTaskConfiguration
屬性

Windows 需求

裝置系列
Windows Desktop Extension SDK (已於 10.0.10240.0 引進)
API contract
Windows.Devices.Printers.Extensions.ExtensionsContract (已於 v1.0 引進)

備註

從列印視窗中的 [更多設定 ] 叫用 UWP 應用程式時,啟用事件會提供 類型為 Windows.UI.WebUI.WebUIPrintTaskSettingsActivatedEventArgs 的事件引數,以公開屬性 Configuration來控制印表機。 這個屬性提供 PrintTaskConfiguration 類型的物件,提供列印工作延伸模組內容的存取權,也可讓您新增事件處理常式來更新列印票證。

下列 JavaScript 程式碼片段示範如何存取 PrintTaskConfiguration 物件,然後使用該程式碼片段來存取 PrinterExtensionCoNtext 屬性。

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
}

屬性

PrinterExtensionContext

取得列印工作延伸模組的內容。

事件

SaveRequested

由應用程式的列印視窗引發,以通知裝置應用程式必須更新列印票證。

適用於

另請參閱