How ca i change my html document orientation(to Landscape) for printing using WebBrowser control.
var browser = new WebBrowser();
browser.DocumentCompleted += (sender, args) =>
{
var ws = sender as WebBrowser;
//change paper size and orientation
ws.Print();
};
browser.Navigate(path);
I need to change paper size format to C5 and orientation to Landscape before printing. How can i do this without any dialogs?
2. Press Ctrl + A 3. Right click on the page and left click on “Print” 4. Press the “Print” button.
Only Print Text You Highlight on a Page Now in your browser go to File > Print or simply use the Ctrl + P keyboard combination. The Print screen comes up. Select the Printer you want to use. Then under “Print Rage” check the Selection box and click OK.
Right-click the selected text and then select Print in the context menu. Choose the print options you want and then select Print.
To control HTML printing layout beyond @media CSS with WebBrowser
(both WinForms and WPF), you would need to implement your own Internet Explorer Print Template. That would provide full control over headers, margins, columns, etc.
Specifically, you're after TemplatePrinter.orientation. It isn't properly documented, but it works. The source of the standard IE print template can be viewed when navigated to res://ieframe.dll/preview.dlg
.
Some other relevant resources:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With