BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News A Standardized Printing UI for Windows 8

A Standardized Printing UI for Windows 8

Leia em Português

This item in japanese

Windows 8 Metro is bringing with it a lot of changes and printing is no exception. Building upon the charm concept, there is a new API and extendable user interface for printing. This API is available for both XAML and JavaScript-based applications.

Printer support has always been a key selling point for Windows. Its superior support for print drivers is often cited as a key reason why Windows won out over IBM’s OS/2. Yet the user interface aspects of this have long been neglected by Microsoft and each application usually ends up creating its own user interfaces.

The first problem is the standard print dialog exposed by .NET. While it works for basic programs, it offers very little in terms of extensibility. Developers needing to do anything non-standard will end up building their own from scratch. Under Metro application-specific printer options are exposed via the PrintTaskAdvancedOptions class. This has extensibility in the form of text fields and option lists and should work exactly the same in both XAML and JavaScript-based applications.

Another problem is the print preview window, where each program is again responsible for providing its own support for print preview. In Windows 8 Metro solves this by combining the print preview window with the print dialog. Applications that support printing but not print preview will appear to be broken to the user.

The core printing functionality is provided by the Windows.Graphics.Printing namespace. This API is equally usable from both XAML and JavaScript-based applications and in theory results in an identical user experience. With JavaScript-based applications the developer merely needs to register the application for printing and reformat what’s on the screen using CSS using media queries.

With XAML-based applications there is quite a bit more work to do as developers are expected to use XAML to layout the preview and printed pages. Much like WPF and Silverlight printing, one must listen for events raised by an instance of PrintDocument. (This version of the class can be found in the Windows.UI.Xaml.Printing namespace.)

  • AddPage: Indicates that a page is needed for printing
  • Paginate: Triggered when the user changed a setting that may require repaginating the document.
  • GetPreviewPage: Indicates that page is needed for previewing

Because it is based on the Windows.UI.Xaml namespace, printing logic cannot be shared between Metro and desktop-style applications.

Rate this Article

Adoption
Style

BT