Sunday, April 15, 2012

Silverlight Printing

Silverlight printing will be pretty easy when compare to WPF for single and Multiple pages. PrintDocument plays the vital role to print the pages of the document.

Actually PrintDocument class provides 3 events to completely work with the Silverlight Printing.

PrintDocument document = new PrintDocument();
document.PrintPage += new EventHandler<PrintPageEventArgs>(document_PrintPage);
document.EndPrint += new EventHandler<EndPrintEventArgs>(document_EndPrint);
document.BeginPrint += new EventHandler<BeginPrintEventArgs>(document_BeginPrint);
document.Print("Print Document");


BeginPrint will be used to determine the pages to be printed for the document. It just prepares the UI before to print the document.

2. PrintPage:-

It has the PageVisual property in the PrintPageEventArgs. It will just decide the current page visual to be printed.

3. EndPrint:-

EndPrint will release all the resources which have been prepared while begin print event is triggered.

The above events will be getting triggered only when we call the Print("") method. Once this method is called Printing will be started to print all the available pages in the document depend upon of BeginPrint event.

No comments:

Post a Comment