开发者

How to Print reports in Silverlight 4

开发者 https://www.devze.com 2022-12-30 23:28 出处:网络
I am wondering if there is anything built in to S开发者_开发知识库ilverlight, or possibly c# to allow for printing reports?

I am wondering if there is anything built in to S开发者_开发知识库ilverlight, or possibly c# to allow for printing reports?

I'd be happy with any number of methods: exporting files to a pdf format and printing from there, exporting as a text document of some sort and printing from there, or just simply showing the print dialog from the web application itself.

I know there are ways to do this in C#, but the c# code-behind is different for many things in Silverlight applications and I can't seem to find anything that will work.

So if anyone has any ideas on things I could try it would be very much appreciated!


Silverlight does have built-in bitmap printing support since version 4. You can find some good info on Shawn's blog: http://wildermuth.com/2009/11/27/Silverlight_4_s_Printing_Support

As I said, it's only bitmap-based though, with the drawbacks that come with bitmaps (no proper scaling etc.).

Another nice workaround that I like is to convert the data you want to print into a PDF on the server side. You can host a web service on the server, send the data to print from the client to the server through that service and then on the server use e.g. Acrobat Distiller or whatever PDF printing utility you like to generate a PDF file. When PDF generation has finished, the server sends a URL back to the client that points to the newly generated PDF file. In your Silverlight app, you can then simply open that URL in a new window, for instance. This is however more of a PDF export rather than printing, as the PDF will only be opened on the client side but not printed automatically.

PDF generation on the client side in contrast is not possible by default in Silverlight. There are however third-party libraries out there that can do that.

Cheers, Alex


You might also check out Pete Brown's simple Silverlight 4 report writer: http://10rem.net/blog/2010/05/09/creating-a-simple-report-writer-in-silverlight-4

A more full-featured but requirement heavy (needs ASP.NET server side) option is Perpetuum's SharpShooter: http://www.perpetuumsoft.com/Report-Sharp-Shooter-for-Silverlight.aspx

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号