This project is read-only.

Installation Notes

Run the installer Setup.exe to install WP7PrintService.exe and all associated programs dlls to a directory on your machine where the WP7 Print Service will run.

The WP7Print dll will also be installed to the same directory. It is a Compact Framework version, which will only run on a Windows Phone 7 or its emulator.

The installation program will copy to the chosen directory:

The setup will create shortcuts to WP7Config and PrintServerTables in the all-users section of the user menu.

Setup requires Framework 4.0 Client and elevated permissions.


The WP7Print dll operates in one of two ways:

  • If the user or the app know the address of a computer that is running the print service, it can connect to this computer directly in order to print. The address can be a Url or an IP. The address should also have a port number through which the service communicates. This port number can be set at installation of the service or changed later by using the WP7Config program
  • If the user’s organization runs a master server, the app can connect to this address through a url or IP address and port number, and retrieve a list of print servers and their locations, in order to choose the desired print server. The list of print servers in the master server is held in an Xml file that can be maintained through the PrintServerTables program.

In logical terms, the app only needs to navigate to the printer selection function in the WP7Print dll in order to start a check that will verify if a print server is already configured for the app, and if not to show a window where the user can select a master server or directly a print server.

Once this is done, the dll will attempt to connect to the print server and when connected will display the printer choice window from which the user can select a printer, configure its properties and finally print.

WP7Print.dll Documentation

WP7Print.dll is a library that allows for printer selection, printer property settings and printing from a Windows Phone 7 application.

The dll exposes the following classes:

Printer, PrintTicket, PrintCapabilities which correspond one-to-one to the same classes in the System.Printing framework dll that is not available on the WP7.

All relevant enum types are also exposed with the same names as in System.Printing.

A Printers class, defined as List<Printer> is also exposed. This class contains all the Printer available at a specific IP.

The dll operates in conjunction with a Windows Communication Foundation service hosted in a Windows service, communicating via BasicHttpBinding with the service. The service needs to be installed on a computer that is connected to at least one printer, and has the .Net framework 4.0 Client Profile installed.

The dll also exposes the following classes:

A Settings class is provided to store and retrieve the IP address of the computer where the print service is running, and data relative to the print job.

This static class has at present four properties and one enum:

string printerIP { get; set; }

enum PrintType { HtmlText, RtfText, PlainText }

PrintType printType - the type of print (

String jobName - a name for the print job

String sText - the text to be printed



A PrintSetup class is provided in order to check that a WiFi connection is available, and that the IP in the Settings class has been initialized.

This class exposes one method:

       public static bool CheckInternetConnection()

returns true if a WiFi connection is available, false otherwise


The dll contains a set of WP7 pages that allow for choice of printer and changing the settings of the printer.

The App is responsible for formatting the text as needed, and for controlling the return code (empty string if the job has failed, “OK” if it has succeeded)   


Normally, printing is extremely simple, the app needs to:

  1. Check that there is network connectivity.
  2. Set the Settings class print type, job name and text to be printed.
  3. Navigate to the printer selection page
  4. In that page, choose the printer, change the printer settings and print or cancel printing using the Page’s visual interface

            if (!PrintSetup.CheckInternetConnection())


           Settings.printType = Settings.PrintType.HtmlText;

           Settings.jobName = ...a string containing the job name

           Settings.sText = ...a string containing the formatted text to be  printed

           Uri theUri = new Uri("/WP7Print;component/PrinterSelectionPage.xaml", UriKind.Relative);



NOTES when printing Html


When printing Html, the overall document page margins are set by using the leftmargin/rightmargin/topmargin/bottommargin attributes of the <BODY> tag :

<BODY leftmargin=”40” etc. />

The value for each margin can be either a double (23.567 etc) or a double followed by px for pixels and in for inches (32.5px, 0.8in etc, with inches being converted to pixels at 96 pixels to the inch). When neither pixels nor inches is defined, the default is pixels.

When no document page margin is specified, a default value of 0.5 inches (48pixels) is applied.


Last edited Dec 31, 2010 at 7:52 AM by pgmariotti, version 2


No comments yet.