使用C#和PrintPreviewDialog进行多页打印 [英] Multiple Page Printing with C# and PrintPreviewDialog

查看:1278
本文介绍了使用C#和PrintPreviewDialog进行多页打印的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
        {


                SaveAsBitmap(pagina);
                e.Graphics.DrawImage(bmp1, xST, ySUS);
                if (pagina < 6)
                {
                    pagina++;
                    e.HasMorePages = true;

                }
                else
                    e.HasMorePages = false;




        }


好的,所以我有一个PrintPreviewDialog,我试图做的是显示并打印多个页面,每个页面都包含bmp1(位图)中的图像.问题是,即使所有页面都正确显示在我的printPreviewDialog中,当单击左上角的打印"按钮时,也只有最后一页正在打印.有任何想法吗?这让我疯狂.谢谢.

P.S. SaveAsBitmap方法调用给定控件的drawToBitmap方法(要打印的控件由SaveAsBitmap的参数给出).


Ok..So I have a PrintPreviewDialog and what I try to do is display and print multiple pages each containing the image in bmp1 (Bitmap). The problem is that even if all the pages are displayed correctly inside my printPreviewDialog, when clicking the Print button in the top left corner, only the last page is printing. Any ideas? It''s driving me crazy. Thanks.

P.S. The SaveAsBitmap method calls the drawToBitmap method of a given control (the control to be printed is given by SaveAsBitmap''s parameter).

推荐答案

阅读本文
[ ] ^ ]

首先也要使用Extendedrichtextbox构成项目和dll文件
然后您可以解决打印中的任何问题

祝您好运
read this article
[]Word Processor Based Upon an Extended RichTextBox Control[^]

first take extendedrichtextbox form the project and dll file too
and then you can solve any problem in printing

good luck


这真的很简单.当您为PrintPreview执行打印时,它会运行该方法,但它仍将对象包含在内存中.

因此,您的问题不是在完成第一次打印时就将其重置.

更改为此:

Its really easy.. When you execute the print for the PrintPreview it runs the method, but it will still contain the object in memory.

Therefore your problem is not resetting it when the first print was done.

Change to this:

if (pagina < 6)
{
     pagina++;
     e.HasMorePages = true;

}
else
{
     pagina = 0;
     e.HasMorePages = false;
}


这篇关于使用C#和PrintPreviewDialog进行多页打印的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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