如题。C#如果调用系统图片打印向导打印图片?
在网上找到一段代码,可以实现调用windows图片查看器打开指定图片
System.Diagnostics.Process.Start("rundll32.exe", string.Format("{0} {1}", "shimgvw.dll,ImageView_Fullscreen", @"f:\demo.bmp"));
查了些资料好像shimgvw.dll,ImageView_Fullscreen改成shimgvw.dll,ImageView_PrintTo /pt 就是打印。但具体不知道怎么写参数,求教大神帮忙。或者其他办法也行,达到目的即可
------解决思路----------------------
第1步, 你可以将文件读取到 PictureBox
第2步:
拖一个printDocument控件到界面。
打印按钮的代码:
C# CODE:
private void button1_Click(object sender, EventArgs e)//执行打印
{
PrintDialog MyPrintDg = new PrintDialog();
MyPrintDg.Document = printDocument1;
if (MyPrintDg.ShowDialog() == DialogResult.OK) { try
{
printDocument1.Print();
}
catch
{ //停止打印
printDocument1.PrintController.OnEndPrint(printDocument1, new System.Drawing.Printing.PrintEventArgs());
}
}
}
第3步:
设置printDocument控件的PrintPage事件:
private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
e.Graphics.DrawImage(pictureBox1.Image, 20, 20);
}
------解决思路----------------------
参考 http://jingyan.baidu.com/article/b87fe19ebcb9fd521835689f.html