I have this script that is not rendering correctly, firefox shows it but when I try to download the pdf I get corrupt file.
<html>
<head>
<style type="text/css">
</style>
</head>
<body >
<?php
ob_start();
include('config.php');
/* $link = mysql_connect("localhost", "root", "*******");
mysql_select_db("roda", $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>Informe de carga detallada Fecha/Hora.</center>";
echo'<hr>';
echo'<br>';
echo '<table border="0" cellpadding="4" align="" cellspacing="0" >';
echo '<tr>';
echo'<td> </td>';
echo'<td> </td>';
echo'<td> </td>';
echo'<td> </td>';
echo'<td align="right"><b>Número de caso:</b></td>';
echo"<td style='color:red' >$bl3 </td>";
echo'<td> </td>';
echo'<td> </td>';
echo'<td align="right"><b>Cliente:</b></td>';
echo"<td style='color:red'>$bl4</td>";
echo'<td> </td>';
echo'<td><b>Codigo de cliente:</b></td>';
echo"<td>$bl5</td>";
echo'<td> </td>';
echo'<td> </td>';
echo'<td><b>Fecha de creación:</b></td>';
echo"<td>$bl6</td>";
echo '</tr>';
echo'<tr>';
echo'<td> </td>';
echo'<td> </td>';
echo'<td> </td>';
echo'<td> </td>';
echo'<td align="right"><b>Origen:</b></td>';
echo"<td>$bl7</td>";
echo'<td> </td>';
echo'<td> </td>';
echo'<td><b>Cantidad de items:</b></td>';
echo"<td>$bl8</td>";
echo'<td> </td>';
echo'<td><b>Almacenamiento:</b></td>';
echo"<td>$bl9</td>";
echo'<td> </td>';
echo'<td> </td>';
echo'<td align="right"><b>Retención:</b></td>';
echo"<td>$bl10</td>";
echo'</tr>';
echo'<tr>';
echo'<td> </td>';
echo'<td> </td>';
echo'<td> </td>';
echo'<td> </td>';
echo'<td align="right"><b>Comentario:</b></td>';
echo"<td>$bl11</td>";
echo'<td> </td>';
echo'<td> </td>';
echo'<td> </td>';
echo'<td> </td>';
echo'<td> </td>';
echo'<td> </td>';
echo'<td> </td>';
echo'<td> </td>';
echo'<td> </td>';
echo'<td> </td>';
echo'<td> </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> </th>';
echo' <th> </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> </th>';
echo' <th>Comentario</th>';
echo' <th> </th>';
echo' <th>Foto</th>';
echo' <th> </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'];
$imageURL = "img/".$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> </td>';
echo"<td align='center' > $d </td> ";
echo'<td> </td>';
echo"<td align='center' > $e </td> ";
echo'<td> </td>';
echo"<td align='center' > $f </td> ";
echo'<td> </td>';
echo"<td align='center' > $g </td> ";
echo'<td> </td>';
echo"<td align='center' > $h </td> ";
echo'<td> </td>';
echo"<td align='center' > $i </td> ";
echo'<td> </td>';
echo"<td align='center' > $j </td> ";
echo'<td> </td>';
//echo"<td img src='img/$imageURL'> </td>";
?>
<td> <?php echo "<img src='$imageURL'/>";
?> </td>
<?php
// echo"<td> <img src='/var/www/roda/img/noimage.jpg' /> </td>";
echo'<td> </td>';
echo'</tr>';
}
echo' </table>';
?>
<?php
require_once("dompdf/dompdf_config.inc.php");
$dompdf = new DOMPDF();
$dompdf->load_html(ob_get_clean());
$dompdf->set_paper('letter', 'portrait');
$dompdf->render();
$pdf = $dompdf->output();
$filename =".$bl3.".pdf;
$dompdf->stream($filename, array("Attachment" =>0));
?>
</body>
</html>