다음을 통해 공유


Printing (XAML)

These topics describe how to print content from a Windows Store app that is built with C#, Visual Basic, or C++, and XAML.

These topics assume that you already understand how to write programs with C#, Visual Basic, or C++, and XAML, and so they focus on the techniques that are specific to printing from Windows Store apps that are built with C#, Visual Basic, or C++, and XAML.

Overview

To print from an app in Windows 8, the app must access Windows printing and provide the formatted content to be printed.

Accessing Windows printing

Your app accesses Windows printing by registering for the Print contract in each view of the app from which you want users to be able to print. Registering for the Print contract means obtaining a PrintManager object, creating a PrintTask object, and handling the PrintDocument events. The topics in this section describe this process in greater detail.

After an app has registered for the Print contract, it can use the default print UI that Windows provides, or it can customize it by adding or removing printing options. How to change standard options in the print preview UI and How to add custom options to the print preview UI describe how to customize the print experience in Windows.

Windows printing provides a preview feature to all apps that have registered for the Print contract. Windows Store apps should use the print-preview functions of Windows printing instead of showing print-preview content in the app itself.

Providing formatted content to print

Windows printing requires the app to format the content for the printer. After your app has registered for the Print contract, Windows will raise printing events that correspond to different aspects of the printing process. Your app must format and return the content required by the event. The topics in this section show how to handle these events in a Windows Store app.