开发者

Silverlight - Printing

I have a Silverlight application that has a DataGrid. I need to print the selected items in the DataGrid. However, I do not want to use a WritableBitmap. Is there a way for me to pass just those items to either a WCF Service or a .aspx page and render HTML that will prompt the user to print? 开发者_Python百科If so, how?

Thank you,


If you're using Silverlight 4, you could use the printing API, but I guess you would not ask this question in this case.

In Silverlight 3, I think you have to resort to some kind of hack, where you SL code calls a JavaScript function, giving it the selected data in some format. This function could open a new window where the data is re-displayed in a print-friendly format and then printed.

I mention a new window, because I guess the window hosting the SL content already has some content that is unrelated to the data to print.


Prior to SL4:

  1. Create a WCF service that:
    • takes in an XML blob
    • renders it as PDF (one way to do that is to use FO)
    • stores it in some temp area with unique id
    • returns the id to the client
  2. Create an .aspx page that:
    • takes in an id of a PDF file returned by WCF service
    • streams the generated PDF to the client (with proper Content-Type)
  3. SL client:
    • invokes WCF service and gets the id of the generated PDF file
    • constructs the URL of the generated PDF file
    • uses any of JavaScript tricks to popup that URL in the browser (one way is to have a hidden IFRAME and set its source to the URL)
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜