I'm looking for an example of how to load an image from file and print it on a page using WPF. I'm having a hard time finding good information about WPF printing.
A:
Just load the image and apply it to a visual. Then use the PrintDialog to do the work.
...
PrintDialog printer = new PrintDialog();
if (printer.ShowDialog()) {
printer.PrintVisual(myVisual, "A Page Title");
}
MojoFilter
2008-11-05 13:26:50
+9
A:
var bi = new BitmapImage();
bi.BeginInit();
bi.CacheOption = BitmapCacheOption.OnLoad;
bi.UriSource = new Uri("");
bi.EndInit();
var vis = new DrawingVisual();
var dc = vis.RenderOpen();
dc.DrawImage(bi, new Rect { Width = bi.Width, Height = bi.Height });
dc.Close();
var pdialog = new PrintDialog();
if (pdialog.ShowDialog() == true) {
pdialog.PrintVisual(vis, "My Image");
}
Tamir
2008-11-05 13:41:46
A:
If you want more control then PrintDialog.PrintVisual gives you you have to wrap your image in a FixedDocumet.
You can find simple code that creates a fixed document here: http://www.ericsink.com/wpf3d/B_Printing.html
Nir
2008-11-05 14:48:18
You should better ask this as a new question, more people would look at it and try to help you. (And it's not an answer to this question, so not very helpful here in that respect.) Also make sure to include enough details in your question.
sth
2009-12-14 09:43:21