Car*_*pez 32 c# printing image picturebox
我在PictureBox中有一个图像,我想打印它.没有格式化,没有任何东西,只需打印它.
我一直在Google上搜索,但我什么都没有,只有人打印表格或文字或报告.
private string imgSrc;
public string ImgSrc
{
get { return imgSrc; }
set { imgSrc = value; }
}
public Id_Manager()
{
ImgSrc = "D:\\Foto.jpg";
InitializeComponent();
idPicture.Load(this.ImgSrc);
}
Run Code Online (Sandbox Code Playgroud)
显然图像会发生变化,但现在我只对打印图像感兴趣.为了以防万一,我将URL保存在属性中.有帮助吗?
Rob*_*ing 59
下面的代码使用PrintDocument对象,您可以将图像放在printdocument上然后打印它.
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);
}
Run Code Online (Sandbox Code Playgroud)
Chu*_*age 10
使用该位置,我有这个FileInfo扩展方法,它做到了:
public static void Print(this FileInfo value)
{
Process p = new Process();
p.StartInfo.FileName = value.FullName;
p.StartInfo.Verb = "Print";
p.Start();
}
Run Code Online (Sandbox Code Playgroud)