I want to print an HTML page the way it is, without any additional content such as URL and date.
Some people told me that you cannot do it using CSS/JavaScript because those additional stuff are from the browser/printer.
The user who will print the page is using the server machine. The browser will be the interface and PHP can be used in conjunction to print.
What would be the best way to do it?
I want to print an HTML page the way it is, without any additional content such as URL and date.
Some people told me that you cannot do it using CSS/JavaScript because those additional stuff are from the browser/printer.
The user who will print the page is using the server machine. The browser will be the interface and PHP can be used in conjunction to print.
What would be the best way to do it?
Share Improve this question edited Apr 10, 2013 at 0:15 user937450 asked Apr 10, 2013 at 0:05 user937450user937450 7335 gold badges11 silver badges20 bronze badges 6- 1 What do you mean by "machine printing page is server itself"? Is the server doing the printing not printing the page via a browser? – Charlie Gorichanaz Commented Apr 10, 2013 at 0:07
- If you are referring to the information that gets printed in the header and footer of the document, then yes, those are generated by the browser or the printer (print settings). Are you referring to something else? Are you using a browser to print? – Revent Commented Apr 10, 2013 at 0:09
- I think in CSS3 there are features for this. But never tested. I had the problem once too I couldn't solve it – hek2mgl Commented Apr 10, 2013 at 0:10
- @Charlie Gorichanaz The user is opening the page via browser on the server machine. That means that if its possible to do what i want server-side it will work too. – user937450 Commented Apr 10, 2013 at 0:10
- See this answer for some ideas, but generally you want to do this via the browser's print settings. stackoverflow.com/a/2780518/172602 – Charlie Gorichanaz Commented Apr 10, 2013 at 0:14
3 Answers
Reset to default 10The URL, date, and page title, and other information that are often printed in the header and/or footer are controlled by the web browser. Unfortunately, you cannot control these via CSS or HTML. It is up to the visitor of your site to decide whether or not they want these elements to print.
Users can turn off headers and footers by following the steps below. (Steps may vary based on browser version, or may even be unavailable on older browsers. All steps done in the latest version of each browser.)
Chrome
- Click the icon in the top right corner of the browser.
- Click Print.
- Uncheck Headers and Footers under the Options section.
Firefox
- Click in the top left corner of the browser.
- Place your mouse over Print, the click Page Setup.
- Click the Margins & Header/Footer tab.
- Change each value under Headers & Footers to
--blank--
.
Internet Explorer
- Click the icon in the top right corner of the browser.
- Place your mouse over Print, then click Page Setup.
- Change each value under Headers and Footers to
-Empty-
.
You can do it including a page media CSS rule in your page:
<style>
@page {
size: auto;
margin: 0;
}
</style>
In google chrome you can turn off additional content when you print.
In the options section at the bottom left, turn off "headers and footers".
https://storage.googleapis.com/support-kms-prod/SNP_2703025_en_v0