Printing in Silverlight


Introduction

In this article we will see how the Print API can be used in Silverlight 4.

Create Silverlight Application

Fire up Visual Studio 20102010 and create a Silverlight Application and name the solution as PrintAPISample.

1.gif
 
Let's have some control's that would signify the printing.

2.gif 

As you see in the above image, we have a Tab control and it consits of two Items, which contains an image each. Then we have a Hyperlink "Print Page", which will print when we click on it.

Let's write the code for printing.

We need the following Namespace to use the Printing classes.

3.gif

4.gif
 
Now let's run the application and click to Print Page.

5.gif 

When we click on print the Print Dialog box would open.

Unfortunately the Printer driver is not supported in Windows 7 and I haven't updated so let's print it as a PDF file.

6.gif 

And when the print is completed the file would look like following.

7.gif 


Hope this article helps.

Recommended Readings

erver'>

Similar Articles