日期:2014-05-19  浏览次数:21075 次

请问PrintDocument打印时怎么去掉那个一闪而过的小窗体,令求图片打印的源码
每次用PrintDocument打印时都会出现一个小窗体,上边写着“Page   1   of   the   Document”,因为做触摸屏软件,所以不希望用户看到这个东东,而且我是抓屏幕上的窗体,转化为图片打印,所以求一份C#的图片打印源码。

------解决方案--------------------
ding……
------解决方案--------------------
1. 定义类:
using System;
using System.Windows.Forms;
using System.Drawing;
using System.Drawing.Printing;

namespace Tif
{
/// <summary>
///
/// </summary>
public class TIFFPrint
{
public PrintDocument pd= new PrintDocument();
public string m_currentFiles;

public TIFFPrint()
{
//
// TODO: Add constructor logic here
//
pd.PrintPage+=new PrintPageEventHandler(pd_PrintPage);
}
public void PrintSingleFile(string strFilename)
{
m_currentFiles = strFilename;
PrintDialog printDialog = new PrintDialog();
printDialog.Document = pd;
if (DialogResult.OK == printDialog.ShowDialog())
pd.Print();
}

private void pd_PrintPage(object sender, PrintPageEventArgs e)
{
Image bitmap = Bitmap.FromFile(m_currentFiles);
if (bitmap != null)
e.Graphics.DrawImage(bitmap,e.PageBounds.Left, e.PageBounds.Top);
}

}
}


2. 调用
TIFFPrint tp = new TIFFPrint();
tp.PrintSingleFile(@ "d:\tmp\3.tif ");