开发者

What is the simplest way to print a series of full-page images from a WPF application?

开发者 https://www.devze.com 2022-12-18 17:03 出处:网络
I have a series of images (just stored locally on disk) that I would like to print, one-per-page, possibly scaled up/down if necessary and centered.

I have a series of images (just stored locally on disk) that I would like to print, one-per-page, possibly scaled up/down if necessary and centered.

What is the most straightforward method of doing this from a WPF appl开发者_如何转开发ication?

Is it to somehow create an XPS document and if so then how? If not, what other possibilities are there? (e.g. PrintDocument from System.Drawing?)


You can use PrintDialog.PrintVisual to print anything that derives from System.Windows.Media.Visual, for example a System.Windows.Controls.Canvas, or a System.Windows.Controls.Image.

PrintDialog dlg = new PrintDialog();
if (dlg.ShowDialog())
{  
  dlg.PrintVisual(visualCtrl); 
}


Today I found Open-Source .NET WPF Reporting Engine. I didn't try it, but I expect it can do images, and on home page it says it can do XPS.

0

精彩评论

暂无评论...
验证码 换一张
取 消