studiothat
studiothat

Reputation: 943

Set print orientation to landscape with a c# Winforms WebBrowser Control

I need to programmatically change the print orientation for one of my webbrowser controls in a winforms app. From what I'm reading in other posts... it looks like the only way to do it is via a programmatic registry edit, print, then change the registry back.

Is this the only solution? If so, can anyone help with the correct way to do this in code?

Upvotes: 1

Views: 3405

Answers (2)

Vins
Vins

Reputation: 71

I figured... Here's how its done in WPF:

var dialog = new PrintDialog(); 

if (dialog.ShowDialog() == true) 
{
     System.Printing.PrintTicket pt = dialog.PrintTicket;
     pt.PageOrientation = System.Printing.PageOrientation.Landscape;

     dialog.PrintTicket = pt;

     // Print the element. 
     dialog.PrintVisual(ReportContentPresenter, "Report"); 
} 

Weird part here is that though, you'll not find PrintTicket in System.Printing even after adding reference to this DLL. You'll also have to add a reference of ReachFramework to get PrintTicket in the intelisense.. Microsoft never stops creating mysteries out of simple things..!! Enjoy!

Upvotes: 2

KrisTrip
KrisTrip

Reputation: 5043

Have you tried: printDialog.Document.DefaultPageSettings.Landscape = true;

Upvotes: 0

Related Questions