How to print a List<string> in Silverlight 4 Beta over multiple pages?!

How to print a List<string> in Silverlight 4 Beta over multiple pages?!

On several people are asking how to print the values of a DataGrid in Silverlight. You cannot just assign the DataGrid to the PageVisual-Property of the PrintPageEventArgs. This would just print the DataGrid as it is on one page. The data wouldn’t be splitted on several pages, cause there’s no paging logic to use. You’ve to write this logic.

You’re responsible for the paging! But how to do it? In this post I’ll give you a little idea how it could work by simple printing out a List of string-values. I won’t talk a lot about the details. Just look at the code below:

When the Button_Click-Eventhandler is executed, the List gets printed over 5 pages. You can easily print it to PDFCreator or XPS Printer to test it. The output looks like this:


Download the source here and enjoy. Give me feedback by entering a comment to this blogentry or via email on

Share this post

Comments (4)

  • neha

    Nice article, helped me a lot. Thanks

    June 4, 2010 at 4:08 am
  • Rasheed


    We are building a large scale Silverlight 4.0 based LOB application for one of our clients. We have a requirement to design data entry forms in Silverlight. After the user fills and submits the data, the form should be converted to PDF. The PDF output should *exactly* match the Silverlight form in terms of document’s layout, fonts, and other visual styles both on screen and printed media. This is required to meet the PDF specification defined by government agencies.

    We would like to know if Silverlight 4.0 is capable of meeting this requirement as this is one of the key scenarios that the system should address. Can you please provide some direction here?


    July 9, 2010 at 3:31 pm
  • Virendra Kumar

    I am developing silverlight application . my canvas size is like 8000(width) & 2000(height) .i want to print entire canvas in single page but it is not clear even i am generating pdf for printing .
    i would like to know how we can print entire canvas in single page with clearity.


    June 27, 2012 at 1:49 pm
    • Thomas Claudius Huber

      Hi Virendra,

      Normally I scale the Canvas down with a Rectangle and a VisualBrush. Maybe you can create a Bitmap and send it to a server-side reporting engine that creates a pdf with a high dpi-setting

      July 3, 2012 at 7:36 am

Comments are closed.