This topic describes best practices to use when printing content from Windows Store apps.
In general, printing content from a Windows Store app follows a similar pattern regardless of the language used to program your app. There are specific HTML and XAML extensions to make it easy for apps using these visual frameworks to print content.
General best practices for printing from a Windows Store app
When you print from your Windows Store app, follow these general guidelines. For more detailed information about coding the specific print tasks mentioned here, see PrintTask, PrintTaskRequested and PrintManager.
| Practice | Description |
|---|---|
|
You must register an event handler that runs when the app is ready to print. |
Your PrintTaskRequested event handler should do the minimal amount of work possible to create the print task. Save more expensive work for when the PrintTaskSourceRequestedHandler is called to retrieve the printable content. |
|
You should unregister the event handler when your app could not print. |
When you unregister the event handler, this lets Windows know that your app cannot print at the present time. This ensures that the print flow runs smoothly and doesn’t fail due to a lack of content to print. |
|
Don't use a print button in your app unless there's no other choice. |
This ensures that the users invoke the print experience through the Devices Charm. If printing is the natural completion of a particular workflow, it is appropriate to add an in-app print button at an appropriate location. For example, a user might expect to see a button to printing a boarding pass after an airline check-in workflow and using the print charm might not complicate the interaction. |
|
You should keep error messages to two lines or less. |
When a user makes an invalid entry in the print preview window, you can display an error message to alert the user about the invalid entry and the corrective action. We recommend that this information take up no more than two lines of text. |
|
You should debug issues in your app. |
For more information about debugging issues in your app, download the white paper Developing Windows Store device apps for printers. |
Best practices for deciding how to create your printed content
You have a fair amount of flexibility when deciding how to generate your print content. In most cases it is easiest to print using the same technology in which you are developing the rest of your app. For example, if you are writing in HTML5 and JavaScript, it is typically easier to use HTML5 and JavaScript concepts to manage your printed content.
Note Blob contents can only be printed in full fidelity when you use a reusable URL. For more information, see Accessing the file system efficiently.
The Print Sample sample app provides examples in JavaScript and HTML, Visual Basic, C++, and C#.
Best practices for customizing settings in the print window
Customizing the settings in the print window gives the app developer the flexibility to change how the printer settings (and options) are presented to the user. For more information, see PrintTaskOptions. The following table explains these recommended practices.
| Practice | Description |
|---|---|
|
You should not change the order of the settings shown in the print window unless it is necessary. |
The order of the settings shown to the user is customizable. However, to maintain consistency in the experience, you are encouraged to retain the default order of the settings and add more settings to the list if necessary. For example, the Copies settings are listed first in the default print experience, and users expect this listing order in your app’s print experience too. |
|
You should not add more printer settings to the print window unless it is necessary. |
Some printer settings and their behavior can be specific to the printer. It is better for the printer manufacturer to handle the addition of such settings. If the printer manufacturer made printer-specific settings available for your printer, then users of your app can click More Settings in the print window to invoke the Windows Store device app that displays those additional settings (if this Windows Store device app has been installed). |
Security Considerations
The following articles provide guidance for writing secure C++ code:
Related topics
- Beyond Print Preview
- Print Sample sample app
- PrintManager
- PrintTask
- PrintTaskOptions
- PrintTaskRequested
- PrintTaskSourceRequestedHandler
Build date: 11/22/2012