7

I am printing web page using Javascript but I got header and footer contain page title, file path, page number, and date. How do I remove them?

I found similar questions related to this problem like below

But every solution says to set margin:0 in @page

I tried that as

@page {
    size: A4 landscape;
    margin: 0;
}

body {
    margin: 30pt;
}

It works fine on the first page of my printed page. From the second page onwards, the margin goes to zero.

I have also tried moznomarginboxes but which is deprecated now.

dland
  • 4,319
  • 6
  • 36
  • 60
PranavPinarayi
  • 3,037
  • 5
  • 21
  • 32

1 Answers1

0

This removes the unwanted data:

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

@page {
  size: auto;
  margin: 0;
}

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

VXp
  • 11,598
  • 6
  • 31
  • 46