How to set printing options via javascript?

5

Is it possible? I would for example remove the default margin and remove header and footer. Now open the print window with these options set.

    
asked by anonymous 03.06.2014 / 16:14

2 answers

6

It is possible using CSS, using the media type print

Suppose you want to hide the header tag when prompted to print:

<header>
   <h1> Preciso sumir na impressão</h1>
<header>
<p> Eu quero aparecer na impressão </p>

In your CSS, you should define:

@media print {
  header {
    display: none
  }
}
    
03.06.2014 / 16:39
4

These are browser settings, not page settings. Some time ago I researched a lot on the subject as well and ended up solving the problem by setting these print settings as browser settings in the pre-document system requirements.

So unless JavaScript is possible to manipulate browser settings, no can be done.

    
03.06.2014 / 16:31