开发者

Silverlight 4 Printing: Getting a Blank Page

Trying to implement a simple print in SL4. I have a DataGrid that I would like to print out, but thus far whatever I try to print out comes out as a blank page in the printer. It also seems to take about 30-60 seconds to actually print out (but that could be an unrelated issue).

My code is fairly straightforward:

private void MenuPrint_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
     开发者_StackOverflow       PrintDocument document = new PrintDocument();
            document.PrintPage += (s, args) =>
                {
                    args.PageVisual = this.MainDataGrid;
                    // args.PageVisual = this.LayoutRoot;
                };

            // Print
            document.Print("Test Print Job");
        }

I've even wondered if it is because the items are too large?

The XAML for the MainDataGrid control is fairly straight-forward as well:

<sdk:DataGrid Grid.Row="3" AutoGenerateColumns="True" Name="MainDataGrid" FontSize="10" Visibility="Visible" />


the only difference I can see between your example and the MSDN one is that you're using an anonymous method for the PrintPage event handler. Have you tried to handle the EndPrint event to check for errors?


Turns out this was PC-related and not a code issue after all. For whatever reason, the same code started working today (after a machine reboot).

The one thing that is still a problem is that the Silverlight interface does seem to hang for about 30-60 seconds while the printing is happening, but it eventually does release and print./


There is a problem in Silverlight 4 printing when sending large amount of data on some printers, I have not seen a good explanation to this problem yet, but here are some links that address this problem.

http://forums.silverlight.net/t/219707.aspx/1?Silverlight+4+batch+printing+print+blank+pages+in+xp+Windows+2003+server+

http://forums.silverlight.net/t/206048.aspx/1?PrintDocument+sends+extreme+amounts+of+data+to+printer

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜