title: Creating Reports in Silverlight (either as PDF or send it off to a printer)
body: <p>I have recently attempted to generate reports in Silverlight 4. In my problem domain, these reports either need to go directly to the printer and/or the client-side SL application creates a PDF and allows the user to store it somewhere.</p>
  
  <p>As for the report, it's roughly composed of 50% flow text (incl. enumerations), 30% tables and 20% charts. The flow text part makes it slighty more challenging, as proper line breaking would have to take place.</p>
  
  <p>So far, I have tried the following approaches - each with its own shortcomings that make them not so much feasible:</p>
  
  <ul>
  <li><p>Silverlight's own <code>PrintDocument</code>: technically, there are two major concerns. For one, getting page breaks to work and printing UIElements on it with proper layout is a bit of a dirty hackjob and full of compromises; thankfully that's the part I've managed to get working so far. However, the <code>PrintDocument</code> class always renders all visuals as bitmaps before sending them off; this is not so much fun, if one uses a PDF printer and hopes to still be able to search in / select text. David Poll's approach in "Silverlight and Beyond" <a href="http://www.davidpoll.com/2010/04/16/making-printing-easier-in-silverlight-4/" rel="nofollow">[1]</a> wasn't that helpful as well as it inherently follows the same approach and thus suffers from very similar issues.</p></li>
  <li><p>silverPDF <a href="http://silverpdf.codeplex.com/" rel="nofollow">[2]</a>: a barely documented library that requires to do most of the layout manually (the former approach at least allowed me to re-use Silverlight's layouting engine). So far, I see no way to (for instance) measure paragraphs and the only sample with long flowtext uses hardcoded absolute values for layout rectangles. Also, the developing party seems to be inactive.</p></li>
  </ul>
  
  <p>Personally, I'm now thinking of following an entirely different strategy: simply generate HTML documents. But I was hoping that the community here might have hints for the two approaches above or know other good approaches.</p>
  
  <p>Thanks in advance,
  ~Manny</p>