Disconnect browser header and footer from the print page

I am printing a webpage using Javascript, but my header and footer contain the page title, file path, page number and date. How to remove them?

I found similar questions related to this problem, for example below

But each solution says set margin:0 to @page

I tried it like

 @page { size: A4 landscape; margin: 0; } body { margin: 30pt; } 

It works great on the first page of my printed page. Starting on page two, the margin is zero.

I also tried moznomarginboxes , but now it is deprecated.

+5
source share
1 answer

This removes unwanted data:

 html, body { width: 210mm; height: 297mm; margin: 0 auto; } @page { size: auto; margin: 0; } 

Most likely you will have to adjust margin and font-size if you decide to use it.

+1
source

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


All Articles