Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Default Layout Orientation when printing XPSs using the WPF XPS Viewer

Is there a way to set the Default Layout Orientation when printing XPSs using the WPF XPS Viewer?

My fixed document XPS has its page orientation set to Landscape, the Page Media Size has a width that is longer that its height and it displays correctly in the Viewer as Landscape. Its just that when you hit the print button the Print Dialog preferences are defaulted to Portrait and it prints as such.

I'd rather not have to alter the users default print settings I'd much prefer it if the XPS Viewer would print the XPS as it was designed to be printed.

like image 352
Scott Avatar asked Dec 03 '25 22:12

Scott


1 Answers

Fill the field of the PrintTicket:

  PrintDialog pd = new PrintDialog();
  PrintTicket pt = new PrintTicket();
  pt.PageOrientation = PageOrientation.Landscape;
  pd.PrintTicket = pd.PrintQueue.MergeAndValidatePrintTicket(pd.PrintQueue.DefaultPrintTicket, pt).ValidatedPrintTicket;
  if (pd.ShowDialog() == true)
  {
    ...
  }
like image 126
Lars Avatar answered Dec 05 '25 23:12

Lars



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!