0

I have a webpage, and I am using JavaScript .print();. however, I don't want have the header and footer from the browser(date and url). I had some research from the internet, it is within the browser, are controlled at the operating system/printer driver level and are not controllable at the HTML/CSS/DOM level. so my question is, is there any other options to suppress this with coding? like generate a file first and then print it from the file?

3 Answers3

0

Look into a print.css file. You can actually dictate what gets printed, and only what you want, in a hidden area.

As per this SO thread: Print.css

Community
  • 1
  • 1
durbnpoisn
  • 4,666
  • 2
  • 16
  • 30
  • it is not in the page code, it is the one from browser. how to set it from browser is here: http://lifehacker.com/5603815/how-can-i-get-rid-of-the-url-and-other-text-when-i-print-from-web-pages – user3179429 Jun 05 '14 at 16:15
0

I think you could generate a PDF of the content and then set it to be printed. That way you could avoid the header and footer to be printed.

0

This may be an old question, but I was able to print a webpage without having the URL and date-time (which the browser adds on its own) printed.

I just added @page { margin: 0; }. I tested this to work with Chrome 70 and Firefox 61.

Do remember to specify it in the print media in css by wrapping it in @media all {<css contents here>} or @media print {<css contents here>}. Alternatively, in html tag, <link rel="stylesheet" media="all" href="<css file url>">

Tikiboy
  • 892
  • 10
  • 20