This sample shows how to create a Windows Store device app that can perform print job management and device maintenance. This sample also includes a printer extension library that can be used to access a printer from a Windows Store device app written for Windows 8.1.

This sample only demonstrates new functionality introduced in Windows 8.1. To learn how to extend the print settings and print notifications experience, see the Print settings and print notifications sample.

Windows Store device apps for printers let printer manufacturers create a Windows Store app that serves as a companion to their device. A Windows Store device app includes a StoreManifest.xml file that specifies a device metadata experience ID. Device metadata associates a specific Windows Store app with a specific printer or family of printers. For more info, see Windows Store device apps for printers.

To obtain an evaluation copy of Windows 8.1, go to Windows 8.1.

To obtain an evaluation copy of Microsoft Visual Studio 2013, go to Visual Studio 2013.

Printer Extension Library

The C# sample uses a C# printer extension library to perform print-specific tasks. The printer extension library references a standard .NET library that provides interop functionality with the COM-based printing infrastructure.

The Visual Studio project PrinterExtensionLibrary wraps the COM implementation of the COM interface PrinterExtensionLib. This enables code sharing between printer extensions and Windows Store device apps for printers. You should consider adding any helper objects, convenience methods, or data model code at this layer. For more info about these interfaces, see Printer Extension Interfaces.

Within the PrinterExtensionLibrary project that is included with the PrinterExtension sample project, there are two C# files. These files wrap the contents of PrinterExtensionLib, but additional classes could be added at this layer in order to enable code sharing between printer extensions and Windows Store device apps.

This project may be augmented with any necessary C# files that describe common model layer code necessary to build your printer extension and/or Windows Store device app for printers. Microsoft recommends against updating the existing classes insofar as possible, as this will make it more difficult for manufacturers to incorporate bug fixes to the app samples as they become available.

Related topics

Windows Store device apps
Print settings and print notifications (device app for printer sample)
Windows 8 app samples

Operating system requirements

Client
Windows 8.1
Server
Windows Server 2012 R2

Build the sample

Prerequisites

The Windows Store device app that this sample demonstrates must be linked to your printer using device metadata.

Install the sample

The following steps build the sample and install device metadata.

  1. Enable test signing.
    1. Start the Device Metadata Authoring Wizard from %ProgramFiles(x86)%\Windows Kits\8.1\bin\x86, by double-clicking DeviceMetadataWizard.exe
    2. From the Tools menu, select Enable Test Signing.
  2. Reboot the computer
  3. Build the solution by opening the solution (.sln) file. Press F7 or go to Build->Build Solution from the top menu after the sample has loaded.

  4. Disconnect and uninstall the printer. This step is required so that Windows will read the updated device metadata the next time the device is detected.
  5. Edit and save device metadata. To link the device app to your device, you must associate the device app with your device.

    Note  If you haven't created your device metadata yet, see Step 2: Create device metadata for your Windows Store device app.

    1. If the Device Metadata Authoring Wizard is not open yet, start it from %ProgramFiles(x86)%\Windows Kits\8.1\bin\x86, by double-clicking DeviceMetadataWizard.exe.
    2. Click Edit Device Metadata. This will let you edit your existing device metadata package.
    3. In the Open dialog box, locate the device metadata package associated with your Windows Store device app. (It has a devicemetadata-ms file extension.)
    4. On the Specify Windows Store device app information page, enter the Windows Store app info in the Windows Store device app box. Click on Import Windows Store App manifest file to automatically enter the Package name, Publisher name, and Windows Store App ID.
    5. If your app is registering for printer notifications, fill out the Notification handlers box. In Event ID, enter the name of the print event handler. In Event Asset, enter the name of the file where that code resides.

    6. When you're done, click Next until you get to the Finish page.
    7. On the Review the device metadata package page, make sure that all of the settings are correct and select the Copy the device metadata package to the metadata store on the local computer check box. Then click Save.
  6. Reconnect your printer so that Windows reads the updated device metadata when the device is connected.

Run the sample

To debug the app and then run it, press F5 or use Debug > Start Debugging. To run the app without debugging, press Ctrl+F5 or use Debug > Start Without Debugging.