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?
Asked
Active
Viewed 1,296 times
0
-
Generating a PDF file for example – reto Jun 05 '14 at 16:07
-
yes. something like it, how can I do it? – user3179429 Jun 05 '14 at 16:35
3 Answers
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.
-
thank you for the reply, it sounds like a solution, but how can I do it? a third party app? – user3179429 Jun 05 '14 at 16:33
-
You could use a server-side lib (depending on your server capabilities) to create a PDF version and then just show a link like "print" – Roberto Contardo Wirth Jun 05 '14 at 16:40
-
It is a SharePoint page and the content is dynamic, it is not easy to do in this case. – user3179429 Jun 05 '14 at 16:44
-
I have no exeprience in sharepoint, but I think that was an acceptable answer to your initial question. Please mark it as the answer if you agree. Many thanks. – Roberto Contardo Wirth Jun 05 '14 at 17:02
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