What is the simplest way to print a series of full-page images from a WPF application?
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.
精彩评论