如何在C#中打印Picturebox的多个图像 [英] how to print multiple Images of Picturebox in C#

查看:329
本文介绍了如何在C#中打印Picturebox的多个图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,
如何在运行时中打印图片框的图像?

我要打印所购买产品的条形码,条形码是图片格式的图片,可以在图片框中生成.

如何打印购买商品的多个条形码,应在第一个中打印商品条形码.产品数量,以及列表中的下一个产品条形码.


请在这次聚会中帮助我.

在此先感谢.

Hi All,
How to print a image of an picturebox in runtime?

I want to print barcode of a product purchase, barcode is in a image format an generate in picturebox.

How to print multiple barcode of products purchase,it should print product barcode in no. of quantity of product and after that next product barcode which is in the list.


please help me in this reagard.

Thanks in Advance.

推荐答案

尝试使用此代码来打印图片框的图像

try this code for to print an image of a picturebox

private void button1_Click(object sender, EventArgs e)
        {
            PrintDocument doc = new PrintDocument();
            doc.PrintPage += this.Doc_PrintPage;
            PrintDialog dlgSettings = new PrintDialog();
            dlgSettings.Document = doc;
            if (dlgSettings.ShowDialog() == DialogResult.OK)
            {
                doc.Print();
            }
        }
 
private void Doc_PrintPage(object sender, PrintPageEventArgs e)
        {
             float x = e.MarginBounds.Left;
              float y = e.MarginBounds.Top;
            Bitmap bmp = new Bitmap(this.pictureBox1.Width, this.pictureBox1.Height);
            this.pictureBox1.DrawToBitmap(bmp, new Rectangle(0, 0, this.pictureBox1.Width, this.pictureBox1.Height));
            e.Graphics.DrawImage((Image)bmp, x, y);
        }


您打印哪种图形都没有关系.您需要使用类System.Drawing.Printing.PrintDocument.使用它的想法是:获得System.Drawing.Graphics类的实例,并呈现所需的所有图形基元.

在此处查看代码示例:
http://msdn.microsoft.com/en -us/library/system.drawing.printing.printdocument(v = VS.100).aspx [使用C#简化的.NET打印 [
It does not matter what kind of graphics do you print. You need to use the class System.Drawing.Printing.PrintDocument. The idea of using it is: you obtain an instance of the class System.Drawing.Graphics and render all the graphical primitive you need.

See the code sample here:
http://msdn.microsoft.com/en-us/library/system.drawing.printing.printdocument(v=VS.100).aspx[^], it explains everything.

Also, look at this article:
Simplified .NET Printing in C#[^].

—SA


您应该研究这些
You should study theseBarcode .NET Control[^]link


Best Regard ,
Theingi Win


这篇关于如何在C#中打印Picturebox的多个图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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