ImageMan.Net打印和预览图片

作者:控件中国网   出处:控件中国网   2015-08-10 10:31:49   阅读:5

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;

}

Copyright© 2006-2015 ComponentCN.com all rights reserved.重庆磐岩科技有限公司(控件中国网) 版权所有 渝ICP备12000264号 法律顾问:元炳律师事务所
客服软件
live chat