WPF: How do you print in landscape mode?

found this feature on the internet that works fine ... except that I can't figure out how it prints in landscape orientation by default.

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

How to really set a default value for printing my wpf content in landscape mode?

+3
source share
3 answers
private void PrintClick(object sender, RoutedEventArgs e)
{
    PrintDialog dialog = new PrintDialog();
    if (dialog.ShowDialog() == true)
    { 
==>     printDialog.PrintTicket.PageOrientation = PageOrientation.Landscape;
        dialog.PrintVisual(_PrintCanvas, "My Canvas"); 
    }
}
+7
source

Original answer This has already been answered: Setting PageOrientation for Wpf DocumentViewer PrintDialog

Complete original answer

Edit:

It looks like there is a problem with PrintTicket and print rendering, check: The same question on MSDN

MSDN, , , , xps , PrintTicket .

+2
private void PrintClick(object sender, RoutedEventArgs e)
{
   PrintDialog dialog = new PrintDialog();
   if (dialog.ShowDialog() == true)
      { 
         dialog.PrintTicket.PageOrientation=System.Printing.PageOrientation.Landscape;
         dialog.PrintVisual(this, "First LandScape"); 
      }
 }

You need to add a link to ReachFramework.dll and System.Printing.dll each.

+1
source

All Articles