Programmatically set print page orientation to landscape

We have an ASP.NET C # web application with a printable link. Is there a way to programmatically adjust the orientation to the landscape so that the user can simply press the print button?

+3
source share
3 answers

The short answer is "no." The intentional limitation of browsers is that the page itself cannot override the user's print settings. This should prevent the abuse that I imagine, and causes all kinds of headaches.

One of the possible ways to work is to display your page as a PDF and present it. You can control the print settings for the PDF page.

+3

, ( JavaScript/CSS).

, JavaScript .

CSS @page:

@page {
    size: landscape;
}

.

... .

+6

No, there is no software way to set the orientation. It is fully processed by the browser.

The best you can do is say: "We recommend that you print the page using" Landscape "(or" Portrait ") and hope that the user knows how to do this.

+1
source

Source: https://habr.com/ru/post/1713153/


All Articles