Hello everyone..
How to print web page in PHP
without Header and footer when print button is clicked by user

Thanks in advance

Edited by garyrichard: Tag

5 Years
Discussion Span
Last Post by kamran_FrizCon

You cant determine to what I set my header and footer, nor should you be able to access my hardware settings, think for a moment


I have generated a report...in a php page...
The report has to be printed in landscape mode
each time i have to set in into page setup
.and have to remove header and footers...
Please tell me the css code to do that


There are few steps to print only content on pages

Is your page have dynamic and static contents, well whats type of that contents follow these 2 simple steps

1. create a page without header and footer

That is because when we use print command in webpage whole page with header and footer will print, this is more simple to create a PHP page without any header and footer, only inner contents.
2. use this code to print that page

echo "<a href='javascript:window.print()'>[Click to Print This Page]</a>";

Edited by kamran_FrizCon: n/a


Problem is to print a web page without any header and footer, 'print()' code will print web page as it is looks on the screen. That's why we have to create a new page without header and footer so that these two things didn't show in that page and can get print only contents of that page


That is an other way to create div's for header and footer and on print command we can hide these through css, and even can some JavaScript, i just give the simple solution without creating new css or writing any JavaScriptto create new page. Well we can also create only one css for all header and footer,"named as media_css" and use on the pages where we want to print the page, when the print command executed "media_css" will automatically applied and hide header and footer

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.