Skip to content
This repository has been archived by the owner on Feb 20, 2021. It is now read-only.

Latest commit

 

History

History

Print job management and printer maintenance

Print job management and printer maintenance

Requires

  • Visual Studio 2013

License

  • MS-LPL

Technologies

  • Windows Runtime

Topics

  • printer
  • Devices and sensors
  • Windows Store device app

Updated

  • 11/25/2013

Description

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.

  • PrinterExtensionTypes.cs specifies a number of helpful enumerations, constants and interfaces that wrap the COM PrinterExtensionLib APIs.

  • PrinterExtensionAdapters.cs specifies all of the constructable classes used to wrap the COM PrinterExtensionLib APIs.

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.

  • You need a copy of the device metadata package for your printer, to add the device app info to it. If you don’t have device metadata, you can build it using the Device Metadata Authoring Wizard as described in the topic Step 2: Create device metadata for your Windows Store device app.

    Note  To use the Device Metadata Authoring Wizard, you must install Microsoft Visual Studio Professional 2013, Microsoft Visual Studio Ultimate 2013, or the standalone SDK for Windows 8.1 before completing the steps in this topic. Installing Microsoft Visual Studio Express 2013 for Windows installs a version of the SDK that doesn't include the wizard.

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.