Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Print HTML page without additional content (URL, date, etc)

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?

like image 245
user937450 Avatar asked Apr 10 '13 00:04

user937450


2 Answers

The 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

  1. Click the Menu icon in the top right corner of the browser.
  2. Click Print.
  3. Uncheck Headers and Footers under the Options section.

Firefox

  1. Click Firefox in the top left corner of the browser.
  2. Place your mouse over Print, the click Page Setup.
  3. Click the Margins & Header/Footer tab.
  4. Change each value under Headers & Footers to --blank--.

Internet Explorer

  1. Click the Gear icon in the top right corner of the browser.
  2. Place your mouse over Print, then click Page Setup.
  3. Change each value under Headers and Footers to -Empty-.
like image 67
Michael Irigoyen Avatar answered Oct 20 '22 00:10

Michael Irigoyen


You can do it including a page media CSS rule in your page:

<style>
  @page {
    size: auto;
    margin: 0;
  }
</style>
like image 21
ianaya89 Avatar answered Oct 20 '22 00:10

ianaya89