We have an ASP.NET C# web application with a "printer friendly" link. Is there a way to programmatically set the orientation to landscape, so the user can just press the print button?
This is something that would have to be done on the client side (using JavaScript/CSS).
Unfortunately, JavaScript does not have the ability to make this change.
CSS does have a means of specifying landscape printing via the @page directive:
@page {
size: landscape;
}
CSS Paged Media is well supported by Chrome v15+ and Opera v15+, is partially supported by Firefox v19+, IE8+ and all versions of Edge. However it is not supported by Safari at all
https://caniuse.com/#feat=css-paged-media
The short answer is "No." It is a deliberate limitation of browsers that the page itself cannot override the user's print settings. This is to prevent abuse I would imagine and causes all sorts of headaches.
One possible work around would be to output your page as a PDF and present that. You can control the print settings for a PDF page.
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