打印图像C#.NET [英] Print images c#.net

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

问题描述

我有一个形象在PictureBox,我想打印。没有格式化,什么都没有,只是打印出来。

I have an image in a PictureBox, and I want to print it. No formatting, no nothing, just print it.

我一直在寻找在谷歌,但我已经没有什么,人们只打印表格或文字或报告。

I've been searching on Google but I've got nothing, only people printing forms or text or reports.

private string imgSrc;

    public string ImgSrc
    {
        get { return imgSrc; }
        set { imgSrc = value; }
    }

    public Id_Manager()
    {
        ImgSrc = "D:\\Foto.jpg";

        InitializeComponent();
        idPicture.Load(this.ImgSrc);
    }



显然,图像会改变,但现在我只是感兴趣在打印的形象。我只是在情况下保存URL中的属性。任何帮助吗?

Obviously the image is going to change, but for now I'm just interested in printing that image. I'm saving the url in a property just in case. Any help?

推荐答案

下面的代码使用的PrintDocument对象,将其放置到PrintDocument的一个图像,然后打印出来。

The Code below uses the PrintDocument object which you can place an image on to the printdocument and then print it.

using System.Drawing.Printing;
...
protected void btnPrint_Click(object sender, EventArgs e)
{
    PrintDocument pd = new PrintDocument();
    pd.PrintPage += PrintPage;
    pd.Print();       
}

private void PrintPage(object o, PrintPageEventArgs e)
{
    System.Drawing.Image img = System.Drawing.Image.FromFile("D:\\Foto.jpg");
    Point loc = new Point(100, 100);
    e.Graphics.DrawImage(img, loc);     
}

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

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