I try to print a letter for making a simple letter merge application. But I'm struggled on how to set the printer options within WPF and .NET 4.
Here's my code:
private void button_Print_Click(object sender, RoutedEventArgs e)
{
PrintDialog pd = new PrintDialog();
if (pd.ShowDialog() == true)
{
pd.PrintTicket.PageOrientation = PageOrientation.Landscape;
pd.PrintTicket.PageMediaSize = new PageMediaSize(865, 612);
pd.PrintVisual(canvas_Letter, "Letter Canvas");
}
}
In the PrintDialog I choose the MP tray, which is feeded with letters of C5 size. Its printing my WPF, but not with the correct positions of the elements. Its like the Margin detects the paper size of a A4 paper. Even if I choose paper size of C5 in the PrintDialog, the print is still out of bounds.
Any idea how to fit the size of C5 to my visual print? It seems like my pd.PrintTicket.PageMediaSize set to 865px width and 612px height doesn't work :/