2

I have a silverlight application which consists of a few tabs, which I would like to print or to generate PDF containing these tabs.
I tried to use StackPanel to add each tab and then use PrintDocument to print what I see, but there is a problem because there are too many tabs, so they don't fit in the size of A4 document.
And more, when I resize the browser to a smaller size, only the visible part of the content gets printed.

Is there a different method to print all the content in one document or PDF?

Shimmy Weitzhandler
  • 101,809
  • 122
  • 424
  • 632
user1123432
  • 368
  • 3
  • 8

1 Answers1

1

The PrintPageEventArgs in the PrintPage handler contains the size of the paper so you can calculate how much can be printed on a single page.

Printing (a part of) the visual tree has its disadvantages; what looks good on screen might not be good for paper, especially if scrolling and sizing are involved.

A solutions is to design one or multiple Views for printing and simply bind the same ViewModel to the PrintView. A bit like the special CSS for creating a print version of a web page.

If the content doesn't fit you should use more pages.

This article by Charles Petzold is worth reading too

Emond
  • 50,210
  • 11
  • 84
  • 115