为什么在打印长度超过1页的文档时,silverlight会陷入无限循环? .HasMorePages = true [英] Why does silverlight run into an endless loop when printing document longer than 1 page? .HasMorePages = true

查看:182
本文介绍了为什么在打印长度超过1页的文档时,silverlight会陷入无限循环? .HasMorePages = true的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的第一个问题在stackoverflow上。
我试图打印一个长格,它是动态生成的。

  pdoc.PrintPage + =(p, args)=> 
{
args.PageVisual = myGrid;
args.HasMorePages = false;
};

当我使用 args.HasMorePages = false; ,它会打印网格的第一页(尽管它需要一些时间,因为它向差的打印机发送了一个123MB大的位图) - 感谢silverlight 4的打印功能实现。)



但是,当我使用 args.HasMorePages = true; 打印更多页面时,打印作业在内存上运行得非常激烈,首先打印文档的页面 - 有效地禁用我的开发者机器。即使网格只有2页长。



为什么会发生这种情况?
这里有什么可能的解决方法?我在网上发现的一切都是SL严重处理打印问题,但并不是一个真正的解决方案。

解决方案 < > HasMorePages 属性表明Silverlight打印至少还有一页要打印。

因此,当您设置页面事件触发每个要打印的页面时。 HasMorePages 为true,您将获得另一个 PrintPage 事件,如果您始终将其设置为true(因为您的代码似乎在做),您正在创建一个无限循环。

在某些时候,代码必须将 HasMorePages 设置为false。



最终,开发人员需要执行所有分页逻辑并决定每页上显示的内容,Silverlight不会自动为您执行此操作。


My 1st question here on stackoverflow. I am trying to print a long grid, which was dynamically generated.

pdoc.PrintPage += (p, args) =>
        {
            args.PageVisual = myGrid;
            args.HasMorePages = false;
        };

When I use args.HasMorePages = false;, it prints the first page of the grid as it should (although it takes some time, since it sends a 123MB big bitmap to the poor printer - thanks for silverlight 4's print feature implementation.).

However, when I enable printing more pages withargs.HasMorePages = true;, the printing job runs amok on the memory and sends endless copies of the first printing page of the document - effectively disabling my developer machine. Even if the grid is only 2 pages long.

Why does this happen? What is a possible workaround here? All I found on the net is that SL handles printing badly, but not a real solution.

解决方案

The HasMorePages property indicates to silverlight printing that you have a least one more page to print. The PrintPage page event fires for each page to be printed.

Hence when you set HasMorePages to true you will get another PrintPage event, if you always set it true (as your code appears to be doing) you are creating an infinite loop.

At some point the code has to leave HasMorePages set to false.

Ultimately its up to you the developer to perform all the pagination logic and decide what appears on each page, Silverlight does not automagically do that for you.

这篇关于为什么在打印长度超过1页的文档时,silverlight会陷入无限循环? .HasMorePages = true的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆