简体   繁体   English

在WPF中打印固定文档

[英]Printing Fixed document in WPF

I have a fixed document which contains 70 fixed pages approx., When I tried to print that fixed page by the below code, I got exception 我有一个包含大约70个固定页面的固定文档,当我尝试通过以下代码打印该固定页面时,出现异常

code: 码:

PrintDialog dialog = new PrintDialog();
dialog.PrintDocument(FixedDocument.DocumentPaginator, "Print");

Exception : Insufficient memory to continue the execution of the program. 例外:内存不足,无法继续执行程序。

I thought of printing that 70 pages one by one, but I did not get any strike of the way though I surfed though google....Any way....? 我本来打算一口气打印那70页,但是尽管我在google上冲浪,但还是没有得到任何结果。

Interesting problem you have here. 您在这里遇到有趣的问题。 If you found a solution I'm interested in knowing it; 如果您找到了解决方案,我会对了解它感兴趣。 and you should answer your own question if you did solve it. 如果您确实解决了问题,则应该回答自己的问题。

As for printing pages one by one, here's something you could try. 至于一页一页地打印,您可以尝试以下方法。

PrintDialog dialog = PrintDialog();
var doc = FixedDocument.DocumentPaginator; 
for(int i = 0; i < doc.PageCount; i++)
{
    dialog.PrintVisual(doc.GetPage(i).Visual, "Page " + i);
}

This should answer the question, though I don't think I would follow this method since it'll send 70 individual print jobs to the printer. 这应该可以回答这个问题,尽管我认为我不会遵循这种方法,因为它将向打印机发送70个单独的打印作业。 Instead, figure out what's consuming all your resources using the PrintDocument call. 相反,使用PrintDocument调用找出消耗所有资源的资源。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM