Matt Ridge Posted November 11, 2011 Share Posted November 11, 2011 When using Firefox and other browsers they put in the header and footers the information in the page when you print, is there a way through PHP to actually not allow those to be printed or is this a manual option that is going to have to be selected every time I want to print? Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted November 11, 2011 Share Posted November 11, 2011 Are you talking about the URL and page x of x that the browser adds when you print? If you are, every browser I've used has a setting to allow you to shut that off. As far as doing that in php, no you can't. Quote Link to comment Share on other sites More sharing options...
Psycho Posted November 11, 2011 Share Posted November 11, 2011 Right, if you are talking about the headers/footers that the browser inserts the answer is no since PHP has no ability to control what the browser does with the rendered page. However, if you are talking about headers/footers that YOU are putting on your web page and you don't want them displayed if the user prints the page. Then you can use the "@media" control within CSS to define different styles based upon whether the page is viewed in a browser or printed. Just set the display property to none within the "print" media type for those elements you do not want displayed in a printed page. Quote Link to comment Share on other sites More sharing options...
Matt Ridge Posted November 11, 2011 Author Share Posted November 11, 2011 Are you talking about the URL and page x of x that the browser adds when you print? If you are, every browser I've used has a setting to allow you to shut that off. As far as doing that in php, no you can't. Dang, I'm getting a form to show to the Mgt. and honestly I don't need user error to print and show those headers and footers... as most people know the Mgt are the type of people that just don't know how to do the simplest of things unless they are IT, and even then... Quote Link to comment Share on other sites More sharing options...
kicken Posted November 11, 2011 Share Posted November 11, 2011 You could have your script generate a PDF and then print that rather than printing a traditional web page. I don't believe the headers/footers are added in that case. Quote Link to comment Share on other sites More sharing options...
xyph Posted November 11, 2011 Share Posted November 11, 2011 Indeed. Making PDFs with PHP is easy <?php require('fpdf.php'); header( 'Content-type: application/pdf' ); $pdf = new FPDF(); $pdf->AddPage(); $pdf->SetFont('Helvetica','B',16); $pdf->Cell(40,10,'Hello World!'); $pdf->Output(); ?> Using: http://www.fpdf.org/ Quote Link to comment Share on other sites More sharing options...
Matt Ridge Posted November 11, 2011 Author Share Posted November 11, 2011 Sounds like a plan, the only problem I'm seeing is would I have to re-write the entire page to allow PDF printing? Quote Link to comment Share on other sites More sharing options...
xyph Posted November 11, 2011 Share Posted November 11, 2011 Just your output. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.