PrintManager 類別

定義

提供應用程式內列印的進入點。

public ref class PrintManager sealed
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
class PrintManager final
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
public sealed class PrintManager
Public NotInheritable Class PrintManager
繼承
Object Platform::Object IInspectable PrintManager
屬性

Windows 需求

裝置系列
Windows 10 (已於 10.0.10240.0 - for Xbox, see UWP features that aren't yet supported on Xbox 引進)
API contract
Windows.Foundation.UniversalApiContract (已於 v1.0 引進)

備註

PrintManager 類別負責協調 UWP 應用程式的列印流程。 若要使用此類別,您必須先呼叫 GetForCurrentView 方法。 這個方法會傳回目前使用中視窗專屬的 PrintManager 物件。 接下來,您必須為 PrintTaskRequested 事件新增事件接聽程式。 當應用程式透過 ShowPrintUIAsync 方法叫用列印對話方塊時,就會引發此事件。

當 UWP app 註冊其「意圖」列印時,它會使用列印管理員建立列印合約。 在 UWP 列印範例 中,註冊是由 RegisterForPrinting 方法執行。

public virtual void RegisterForPrinting()
{
   printDocument = new PrintDocument();
   printDocumentSource = printDocument.DocumentSource;
   printDocument.Paginate += CreatePrintPreviewPages;
   printDocument.GetPreviewPage += GetPrintPreviewPage;
   printDocument.AddPages += AddPrintPages;

   PrintManager printMan = PrintManager.GetForCurrentView();
   printMan.PrintTaskRequested += PrintTaskRequested;
}

如需更多涉及列印管理員的範例,以及查看 UWP 應用程式中列印案例的一些範例程式碼,請參閱 列印UWP 列印範例

版本歷程記錄

Windows 版本 SDK 版本 已新增值
1607 14393 IsSupported

方法

GetForCurrentView()

擷取與目前視窗相關聯的 PrintManager 物件。

IsSupported()

指出應用程式是否在支援列印的裝置上執行。

ShowPrintUIAsync()

以程式設計方式起始列印內容的使用者介面。

事件

PrintTaskRequested

發生列印要求時引發。 使用者動作或透過 ShowPrintUIAsync 方法以程式設計方式叫用列印,可能會觸發此事件。

適用於

另請參閱