What’s the best way to print a BitmapImage? I come from a background in System.Drawing so I was thinking about converting it to a Bitmap and then printing it, but I’m thinking there’s probably a better way.
Thanks!
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Building upon Drew’s answer, it is best to measure and arrange the container that is handed to the PrintVisual method. This will prevent an image that is larger than a 8.5 x 11 sheet of paper from being cut off. Here is an example of how I printed an image that was partially visible on-screen:
ImageViewer in my example could be replaced with any UIElement container such as a stackpanel, canvas, grid, ect. ImageViewer.Source should be set to the BitmapImage that is ready to be printed.
I got the idea from this page:
http://www.switchonthecode.com/tutorials/printing-in-wpf