Hi to all the php development comunity:

😕 Does anyone know how to remove the header and footer from a php document when the user decides to print the page out?

I have tried to use FPDF to convert the whole php page into pdf so the user can print whithout those headers and footers (the default printer ones that show the url of the printed page and the number of pages).

The problem with the FPDF is that i quite dont uderstand how to inser variables ussing fpdf.
Please help me out.
Here is the code of my php page:

<?php
$host="myserver";
$username="myuser";
$password="mypassword";
$db_name="mydb";

$con = mysql_connect("$host", "$username", "$password")or die("No se puede conectar");
mysql_select_db("$db_name")or die("No se puede selecionar la base de datos");

$query = "SELECT * FROM Sepesca01.comisiones WHERE codigo_comision='".$_POST['comisioncode']."'";

$result = mysql_query($query,$con);

//echo $query;
//exit();
while( $rows = mysql_fetch_array($result))
{
$codigo = $rows[0];
$area = $rows['area'];
$codigoempleado = $rows['codigoempleado'];
$comisionadoa = $rows['comisionadoa'];
$descripcion = $rows['descripcion'];
$autorizo = $rows['autorizo'];
$dia1 = $rows['dia'];
$dia2 = $rows['dia2'];
$mes1 = $rows['mes1'];
$mes2 = $rows['mes2'];

}
$query = "SELECT emp.foto FROM empleados as emp INNER JOIN comisiones as co on co.codigoempleado = emp.Empleado WHERE emp.Empleado = '$codigoempleado'";

$result = mysql_query($query,$con);

while( $rows = mysql_fetch_array($result))
{
$imgurl = $rows[0];

}

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
<!--
.style1 {font-family: Arial, Helvetica, sans-serif}
.style3 {font-family: Arial, Helvetica, sans-serif; font-weight: bold; }
-->
</style>
</head>

<body>
<table border="0" cellspacing="0" cellpadding="0" width="908">
<tr>
<td width="487" valign="top" class="style1"><p><img src="images/escudogobierno.jpg" alt="escudo" width="160" height="180" /></p>
</td>
<td width="421" valign="top" class="style1"><p align="center"><strong>&nbsp;</strong></p>
<p align="right"><strong>OFICIO DE COMISIÓN <?php echo $_POST["comisioncode"]; ?> </strong><br />
Formato SSA-01</p>
<p align="right">CAMPECHE, CAMP., A 29 DE AGOSTO DE 2008</p></td>
</tr>
<tr>
<td colspan="2" valign="top" class="style1"><div align="left">
<table width="152" border="2" bordercolor="#009900">
<tr>
<td height="211
"><div align="center"><?php echo '<img src ="'.$imgurl.'">'; ?></div> </td>
</tr>
</table>
</div>
<div align="right"></div><div align="right"></div></td>
</tr>
</table>
<div align="left"></div>
<p class="style1"><?php echo $codigoempleado; ?> &nbsp;</p>
<p class="style1"><strong>PRESENTE.</strong></p>
<p class="style1">POR MEDIO DEL PRESENTE, ME PERMITO COMUNICARLE A USTED QUE DEBERÁ LLEVAR A CABO LA SIGUIENTE COMISIÓN: </p>

<p>&nbsp;</p>
<p class="style1">A PARTIR DEL <span class="style1"><?php echo $dia1; ?></span> DE<span class="style1"> <?php echo $mes1; ?></span> AL <span class="style1"><?php echo $dia2; ?></span> DE <span class="style1"> <?php echo $mes2; ?></span> DEL PRESENTE AÑO.</p>
<p class="style1">&nbsp;</p>
<p class="style1">OBJETIVOS O TRABAJOS A DESEMPEÑAR:</p>
<table width="915" height="159" border="0">
<tr>
<td width="909" height="155" class="style1"><div align="justify"><span class="style1"><?php echo $descripcion; ?></span></div></td>
</tr>
</table>
<p class="style1">&nbsp;</p>
<p class="style1">POR LO QUE AL TÉRMINO DE LA PRESENTE COMISIÓN DEBERÁ RENDIR EL INFORME CORRESPONDIENTE.</p>
<p class="style1">&nbsp;</p>
<p align="center" class="style1">SIN OTRO PARTICULAR, LE ENVÍO UN CORDIAL SALUDO.</p>
<p class="style1">&nbsp;</p>
<table border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td width="299" valign="top" class="style1"><p align="center"><strong>AUTORIZÓ</strong> </p></td>
</tr>
<tr>
<td height="54" valign="top" class="style1"><p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p></td>
</tr>
<tr>
<td width="299" valign="top" class="style1"><p align="center"><span class="style3"><?php echo $autorizo; ?></span></p> </td>
</tr>
</table>
<p class="style1">&nbsp;</p>
</body>

</html>

    cant you just direct them to another page like, print.php?page=index.php

    and get that to simplify the page for you

      😃It would be the samething , redirecting doest work ,i need to remove footer and header printer default setting .

      Thank you anyway , i did use the FPDF and that worked ok.

        what i meant was something similar to the way vbulletin shows an archive page, the page is exatly the same but is differently formated.

        For example this link

        http://www.phpbuilder.com/board/archive/index.php/t-2100024.html

        was once origioally somewhere in the forum, you could do something similar but make them both active, reccomending uses to print out the new page not the origional

          Unless arturoromero is talking about the page header/footer that is added by the browser when the user prints a page. In which case that header and footer is entirely the user's choice and you have no control over it.

            Thats what im talking about, the header/footer of a browsers print

              Write a Reply...