ImageMan.Net是一款经典的图片和图片文档处理控件,可以进行图片浏览、处理、创建缩略图等,并且还提供OCR、图片注释、文档清洁以及PDF的序列化等,这里主要介绍如何使用代码进行图片的打印预览和打印,具体代码如下:
ImImage image;
PrintDocument pd = new PrintDocument();
pd.PrintPage += new PrintPageEventHandler(pd_PrintScaledPage);
PrintPreviewDialog dlg = new PrintPreviewDialog();
dlg.Document = pd;
dlg.ShowDialog();
...
void pd_PrintScaledPage(object sender, PrintPageEventArgs e)
{
// Create a ScaleCommand object to scale an image to the printable area of the page using the BestFit option
DTI.ImageMan.Commands.ScaleCommand scale = new DTI.ImageMan.Commands.ScaleCommand(e.MarginBounds.Width -
e.MarginBounds.Left, e.MarginBounds.Height - e.MarginBounds.Top);
scale.BestFit = true;
DTI.ImageMan.ImImage tempImg = scale.Process(image);
// Print the scaled image to the graphics object
tempImg.Print(e.Graphics, new Rectangle(e.MarginBounds.Left, e.MarginBounds.Top, e.MarginBounds.Left + tempImg.Width,
e.MarginBounds.Top + tempImg.Height));
tempImg.Dispose();
e.HasMorePages = false;
}