【发布时间】:2014-03-20 18:07:42
【问题描述】:
我需要一次将文件夹中的所有图像发送到打印机。这可以从 Windows 资源管理器中选择所有图像文件,右键单击并选择打印以将所有选定的图像发送到打印对话框,从中我们可以选择打印机设置并继续打印。如何在 c# windows 窗体应用程序中执行此操作?
编辑:我想出了这个,但它只打印最后一页。我应该如何修改?
private void printAllCardSheetBtn_Click(object sender, EventArgs e) {
PrintDocument pdoc = new PrintDocument();
pdoc.DocumentName = "cardsheets";
PrintDialog pd = new PrintDialog();
if(pd.ShowDialog() == DialogResult.OK)
{
PrinterSettings ps = pd.PrinterSettings;
pdoc.PrinterSettings = ps;
pdoc.PrintPage += pdoc_PrintPage;
pdoc.Print();
}
}
void pdoc_PrintPage(object sender, PrintPageEventArgs e)
{
Graphics g = e.Graphics;
string[] sheetpaths = Directory.GetFiles(_sheetDirectory);
Point point = new Point(0, 0);
foreach (string s in sheetpaths)
{
g.DrawImage(new Bitmap(s), point);
}
}
【问题讨论】: