Apr 11 2008 2:48PM GMT
Posted by: Mark Shurmer
WPF, XAML, printing
WPF Printing using PrintVisual
Posted by: Mark Shurmer
To do a simple print in WPF, you can do the following:
PrintDialog prtDlg = new PrintDialog();
if(prtDlg.ShowDialog() == true)
{
prtDlg.PrintVisual(element, “A simple drawing”);
}
This will throw up the XP or Vista print dialog, and then print the element specified, no problems at all.
Actually there are a couple of problems:
- The element is always lined up in the top left of the printed page
- If you haven’t specified any margin, the element might get cut off
- There’s no pagination
- It uses the same device independent system for printing as showing on the screen ,1:96, so an element 96 pixels wide will appear 1 inch wide on the printed paper



You must be logged-in to post a comment. Log-in/Register