在c#中打印printdocument中的更多页面 [英] Printing more pages in printdocument in c#
本文介绍了在c#中打印printdocument中的更多页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我希望在打印项目增加时打印多张图像。我曾经用ex打印项目。
I want to print multiple image when print items are increasing. I used to print item by using ex.
graphic.DrawString("Name of the client/organization", new Font("Courier New", 11, FontStyle.Bold), new SolidBrush(Color.Black), startX + 40, startY + 70);
graphic.DrawString(": " + NameofClient.Text, new Font("Courier New", 11), new SolidBrush(Color.Black), startX + 370, startY + 70);
此处所有项目(查看图片)只需使用graphic.drawsting打印字符串。我只想要菜单项增加跳到第二页
我尝试过:
我尝试使用e.HasMorePages = true但是在打印时它会计算无穷大。
我想知道什么是更好的方法打印多页。
here all the items(see the image ) just print string using graphic.drawsting. i want only if menu items increase jump in to the second page
What I have tried:
and I try with the e.HasMorePages = true but it count infinity when printing.
I want to know what is the better way to print multiple page.
推荐答案
请参阅我对该问题的评论。显而易见的是,硬编码的立即常数不能用于确定打印效果。当你需要更多页面时,它应该是真的,最终它应该变成错误。我不知道还有什么需要解释。
请参阅:
PrintPageEventArgs Class(System.Drawing.Printing) [ ^ ],>
PrintPageEventArgs.HasMorePages Property (System.Drawing.Printing) [ ^ ]。
在您的情况下,多页的情况,右边 - 分配的部分操作数应按以下条件计算:
Please see my comment to the question. It should obvious that having hard-coded immediate constant true cannot work to finilize printing. When you need more pages, it should be true, and eventually it should become false. I don't know what else needs explanation.
Please see:
PrintPageEventArgs Class (System.Drawing.Printing)[^],
PrintPageEventArgs.HasMorePages Property (System.Drawing.Printing)[^].
In your case, the case of multiple pages, the right-part operand of assignement should be calculated on condition:
void myPrintPageHandler(object sender, PrintPageEventArgs ev) {
// ...
ev.HasMorePages = !AllPagesArePrinted(ev);
// where the function AllPagesArePrinted(ev) is on your, it depends on your logic
}
这篇关于在c#中打印printdocument中的更多页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文