FPDF Does not render

0

I have this code that is not rendered to pdf.

<html>
<head>
<style type="text/css">


</style>

</head>
<body  >

<?php

   
 //ob_start();

	   include('config.php');
	  /* $link = mysql_connect("localhost", "root", "******"); 
	   mysql_select_db("****", $link);*/
       if(isset($_GET['id']))
    {
		$id=$_GET['id'];
	
				
	}
	
	$sq = "SELECT * from caso WHERE bl = '$id' ORDER BY id_bl DESC LIMIT 5";
		$result1 = mysqli_query($connex, $sq);
		while($row2 = mysqli_fetch_assoc($result1))
			{
			$bl3=$row2['bl'];
			$bl4=$row2['nom_cli'];
			$bl5=$row2['cod_cli'];
			$bl6=$row2['fech'];
			$bl7=$row2['origen'];
     		$bl8=$row2['cant'];
			$bl9=$row2['alm'];
			$bl10=$row2['ret'];
			$bl11=$row2['coment'];
			}
	   
	   echo"   <head> <style type='text/css'>

.logo{
	position: relative;
    right: 50 px;
	width:75 px;	
	
	
}
body {
    font-family: 'Helvetica';
	font-size: 8px;
}
table {
    border-collapse: collapse;
}
</style>
</head>  ";
	   
      echo "<meta http-equiv='Content-Type' content='text/html; charset=UTF-8' />";
      echo"<img src='logo2.jpg' class='logo' />";
	  
	  echo"<center><h1>Informe de carga Foto.</h1></center>";
	   echo'<hr>';
	   echo'<br>'; 

	  
	  echo '<table  border="0" cellpadding="4" align="" cellspacing="0" >';
 	echo '<tr>';
		echo'<td>&nbsp;</td>';
		echo'<td>&nbsp;</td>';
		echo'<td>&nbsp;</td>';
		echo'<td>&nbsp;</td>';
 		echo'<td  align="right"><b>Número de caso:</b></td>';
 		echo"<td  style='color:red'  >$bl3 </td>";
		echo'<td>&nbsp;</td>';
		echo'<td>&nbsp;</td>';
		echo'<td  align="right"><b>Cliente:</b></td>';
 		echo"<td style='color:red'>$bl4</td>";
		echo'<td>&nbsp;</td>';
 		echo'<td><b>Codigo de cliente:</b></td>';
 		echo"<td>$bl5</td>";
		echo'<td>&nbsp;</td>';
		echo'<td>&nbsp;</td>';  
 		echo'<td><b>Fecha de creación:</b></td>';
 		echo"<td>$bl6</td>"; 
	echo '</tr>'; 
	echo'<tr>';
		echo'<td>&nbsp;</td>';
		echo'<td>&nbsp;</td>';
		echo'<td>&nbsp;</td>';
		echo'<td>&nbsp;</td>';
 		echo'<td  align="right"><b>Origen:</b></td>';
 		echo"<td>$bl7</td>";
		echo'<td>&nbsp;</td>';
		echo'<td>&nbsp;</td>';
  		echo'<td><b>Cantidad de items:</b></td>';
 		echo"<td>$bl8</td>";
		echo'<td>&nbsp;</td>';
		echo'<td><b>Almacenamiento:</b></td>';
 		echo"<td>$bl9</td>"; 
		echo'<td>&nbsp;</td>';
		echo'<td>&nbsp;</td>';
		echo'<td align="right"><b>Retención:</b></td>';
 		echo"<td>$bl10</td>"; 
 	echo'</tr>'; 
	echo'<tr>';
		echo'<td>&nbsp;</td>';
		echo'<td>&nbsp;</td>';
		echo'<td>&nbsp;</td>';
		echo'<td>&nbsp;</td>';
 		echo'<td align="right"><b>Comentario:</b></td>';
 		echo"<td>$bl11</td>";
 		echo'<td>&nbsp;</td>';
		echo'<td>&nbsp;</td>';
		echo'<td>&nbsp;</td>';
 		echo'<td>&nbsp;</td>';
 		echo'<td>&nbsp;</td>';
		echo'<td>&nbsp;</td>'; 
 		echo'<td>&nbsp;</td>';
		echo'<td>&nbsp;</td>';
		echo'<td>&nbsp;</td>';
 		echo'<td>&nbsp;</td>';
 		echo'<td>&nbsp;</td>'; 
 	echo'</tr>'; 
 echo'</table>';
echo "<br>";

echo"<hr></hr>";

	  
	  
   
		$sql = "SELECT * FROM acarga WHERE bl3 = '$id'";
		$result = mysqli_query($connex, $sql);
	 echo' <table  width="100%" height="99" border="0" >';
  echo '<tr>'; 
 echo'   <th>&nbsp;</th>';
  echo'  <th>&nbsp;</th>';
   echo' <th>Cód item</th>';
   echo' <th><label for="textfield3"></label></th>';
   echo' <th></th>';
   echo' <th><label for="textfield4"></label></th>';
   echo' <th>Cód camión</th>';
   echo' <th><label for="textfield5"></label></th>';
   echo' <th>Tipo P.A.</th>';
   echo' <th><label for="textfield6"></label></th>';
   echo' <th>Código P.A.</th>';
   echo' <th><label for="textfield7"></label></th>';
   echo' <th>Destino</th>';
   echo' <th><label for="textfield8"></label></th>';
    echo'<th>Estado de carga</th>';
   echo' <th><label for="textfield9"></label></th>';
   echo' <th>Fecha</th>';
   echo' <th><label for="textfield10"></label></th>';
   echo' <th>Hora</th>';
    echo'<th>&nbsp;</th>';
   echo' <th>Comentario</th>';
   echo' <th>&nbsp;</th>';
   echo' <th>Foto</th>';
   echo' <th>&nbsp;</th>';
   echo '</tr>'; 
    //while($row = mysql_fetch_array($result))
   
   while($row = mysqli_fetch_assoc($result))
   {
	$a=$row['cod_it'];
	$b=$row['bl3'];
	$c=$row['uni_ca'];
	$d=$row['tipo_pa'];
	$e=$row['num_int'];
	$f=$row['dest'];
	$g=$row['estado'];
	$h=$row['fecha'];
	$i=$row['hora'];
	$j=$row['comenta'];
    //$k=$row['ruta_imagen'];
	$imageURL = $row['ruta_imagen'];

  echo'<tr>';
  echo'<td></td>';
  echo'<td></td>';
  echo"<td align='center' > $a </td>   ";
  echo'<td></td>';
  echo"<td  align='center' > </td>   ";
  echo'<td></td>';
  echo"<td align='center' > $c </td>   ";
  echo'<td>&nbsp;</td>';
  echo"<td align='center' > $d </td>   ";
  echo'<td>&nbsp;</td>';
  echo"<td align='center' > $e </td>   ";
  echo'<td>&nbsp;</td>';
  echo"<td align='center' > $f </td>   ";
  echo'<td>&nbsp;</td>';
  echo"<td align='center' > $g </td>   ";
  echo'<td>&nbsp;</td>';
  echo"<td align='center' > $h </td>   ";
  echo'<td>&nbsp;</td>';
  echo"<td  align='center' > $i </td>   ";
  echo'<td>&nbsp;</td>';
  echo"<td  align='center' > $j </td>   ";
  echo'<td>&nbsp;</td>';
 echo"<td><img src='img/$imageURL' width='400' /></td>";
  echo'<td>&nbsp;</td>';
  echo'</tr>';
   
   
   }
   
  echo' </table>';


require('fpdf/fpdf.php');
$pdf = new FPDF();
$pdf->AddPage();
$pdf->SetFont('Arial','B',16);
$pdf->Cell(40,10,'Hello World!');
$pdf->Output();
?>
</body>
</html>

and it is displayed in this way instead of pdf:

    
asked by leonardo rodriguez2 05.06.2018 в 05:34
source

1 answer

0

Al fpdf you can not work with HTML, unless you use an extension, but I recommend you dompdf, you create the pdf based on css and html, the php data you receive by post or get according to your data, it's more easy;)

    
answered by 05.06.2018 / 06:44
source