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 r开发者_运维问答egistry back.
Is this the only solution? If so, can anyone help with the correct way to do this in code?
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!
Have you tried: printDialog.Document.DefaultPageSettings.Landscape = true;
精彩评论