WPF: How do you print in Landscape mode?

michael picture michael · Mar 14, 2011 · Viewed 14k times · Source

found this function online, which works great... except I can't figure out how to default it to print in landscape.

private void PrintClick(object sender, RoutedEventArgs e)
{
  PrintDialog dialog = new PrintDialog();
  if (dialog.ShowDialog() == true)
  { dialog.PrintVisual(_PrintCanvas, "My Canvas"); }
}

How does one actually set the default to print my wpf content to landscape mode?

Answer

Badiboy picture Badiboy · Apr 26, 2012

Edit: Fixed variable name, mentioned by @SHIN JaeGuk

private void PrintClick(object sender, RoutedEventArgs e)
{
    PrintDialog dialog = new PrintDialog();
    if (dialog.ShowDialog() == true)
    { 
        //Set PageOrientation to Landscape
        dialog.PrintTicket.PageOrientation = PageOrientation.Landscape;
        dialog.PrintVisual(_PrintCanvas, "My Canvas"); 
    }
}