Set Printing Preferences from JS

Viewed 52791

From what I can find on the Google, I can't find a way to use Javascript to set my printing preferences (read: margins, orientations, footer, etc).

I am about to tell my boss that what he wants to do isn't possible. I wanted to check will you fine folks priors to doing this. Please let me know.

I found that in Firefox you can use some user_pref(key,val) settings to set up the user's preferences, but that doesn't work for over 90% of my users. I am looking for something that will cover the IE's (as many as possible), Firefox and Chrome.

5 Answers

You can change some preferences.

Like Orientation:

@media print {
    @page {
        size: A1|A4|A5 landscape; /* auto is default portrait; */
    }
}

To hide the footer and header text generated by the default settings, you can do this trick:

@media print {
    @page {
        margin: 0 !important;
    }

    body {
        padding: 75px; /* This will act as your margin. Originally, the margin will hide the header and footer text. */
    }
}

I think you can add also some text on Header and Footer part but still not tried. You may refer here. https://www.w3.org/TR/css-page-3/#at-ruledef-right-top

Related