Reputation: 183
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?
Upvotes: 4
Views: 9791
Reputation: 8266
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
Upvotes: 8
Reputation: 56391
No, there is no programmatic way to set orientation. It's entirely handled by the browser.
The best you can do is say "we recommend you print the page with Landscape (or Portrait)" and hope the user knows how to do it themselves.
Upvotes: 2
Reputation: 17719
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.
Upvotes: 4