如何在Windows应用程序中打印大尺寸的面板 [英] How to print large size of panel in windows application

查看:88
本文介绍了如何在Windows应用程序中打印大尺寸的面板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图打印大小的面板大小(1024,700)。但它不打印面板的所有区域,所以plz帮助任何一个..

i m trying to print lage size of panel like(1024,700).but it not print all area of panel so plz help any one..

推荐答案

面板控制它自己

所以,使用此命令



panel is control it self
so, use this command

PrintDialog myPrintDialog = new PrintDialog();
System.Drawing.Bitmap memoryImage = new System.Drawing.Bitmap(panel1.Width, panel1.Height);
panel1.DrawToBitmap(memoryImage, panel1.ClientRectangle);
if (myPrintDialog.ShowDialog() == DialogResult.OK)
{
    System.Drawing.Printing.PrinterSettings values;
    values = myPrintDialog.PrinterSettings;
    myPrintDialog.Document = printDocument1;
    printDocument1.PrintController = new StandardPrintController();
    printDocument1.Print();
}
printDocument1.Dispose();









比例图片,如果它不适合页面





or scale image if it''s not fit into page

private void panel1_Click(object sender, EventArgs e)
        {
            PrintDialog myPrintDialog = new PrintDialog();
            memoryImage = new System.Drawing.Bitmap(panel1.Width, panel1.Height);

//scaling into small size
            memoryImage.SetResolution(150, 150);
            panel1.DrawToBitmap(memoryImage, panel1.ClientRectangle);
            memoryImage.Save("E:/a.bmp");
            if (myPrintDialog.ShowDialog() == DialogResult.OK)
            {
                System.Drawing.Printing.PrinterSettings values;
                values = myPrintDialog.PrinterSettings;
           
                myPrintDialog.PrinterSettings.DefaultPageSettings.Landscape = true;
                printDocument1.DefaultPageSettings = myPrintDialog.PrinterSettings.DefaultPageSettings;

                myPrintDialog.Document = printDocument1;
                printDocument1.PrintController = new StandardPrintController();
                printDocument1.Print();


            }
            printDocument1.Dispose();
        }

        private void printDocument1_PrintPage(object sender, PrintPageEventArgs e)
        {
            SizeF sz = new SizeF(e.PageBounds.Width - e.MarginBounds.Width, e.PageBounds.Height - e.MarginBounds.Height);
            PointF p = new PointF((sz.Width) / 70, (sz.Height) / 70);
            e.Graphics.DrawImage(memoryImage, p);
        }



注意:我试图在Papersize中打印是A5



快乐编码!

:)


Note : I have tried to print in Papersize is A5

Happy Coding!
:)


这篇关于如何在Windows应用程序中打印大尺寸的面板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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