Foro de elhacker.net

Programación => PHP => Mensaje iniciado por: Legnak en 25 Junio 2013, 20:15 pm



Título: Unable to stream pdf: headers already sent
Publicado por: Legnak en 25 Junio 2013, 20:15 pm
Hola, sucede que estoy haciendo un código para generar PDF con DOMPDF, a la hora de intentar generarlo me suelta este error:
Unable to stream pdf: headers already sent

el código es el siguiente:
Código
  1. $html = '<table width="400" height="300" border="1" align="center" bgcolor="#FFFFFF">';
  2. $html =$html. '<tr><td colspan="2"><center>Grupo oficina JM C.A.</center></td></tr>';
  3. $html =$html.'<tr><td colspan="2"><center>Avenida Venezuela entre Calles 15 y 16</center></td></tr>';
  4. $html =$html.'<tr><td colspan="2"><center>Barquisimeto Estado Lara</center></td></tr>';
  5. $html =$html.'<tr><td colspan="2"><center>Telefono: 0251 2679314</center></td></tr>';
  6. $html =$html.'<tr><td colspan="2"><center>RIF: J-31353985-6</center></td></tr>';
  7. $html =$html.'<tr><td colspan="2"><center>Código de Licencia: L000005427</center></td></tr>';
  8. $html =$html.'<tr><td><center>Fecha: '.date("d/m/Y",time()).'</center></td> <td><center>Código de factura: '.$_GET["id"].'</center></td> </tr>';
  9. $html =$html.'<tr><td colspan="2"><center>Nombre: '.$_SESSION['MM_Username'].'</center></td></tr>';
  10.  
  11. mysql_select_db($database_conexionproductos, $conexionproductos);
  12. $max_q = "select * from factura where id_usuario =".$_SESSION['MM_ID']." and id =".$_GET["id"].";";
  13. $max_exec = mysql_query($max_q, $conexionproductos) or die(mysql_error());
  14. $fix_max = mysql_fetch_assoc($max_exec);
  15. $num = mysql_num_rows($max_exec);
  16.  
  17. if ($num > 0 )
  18. {
  19. $total = 0;
  20. do
  21. {
  22.  
  23. $arreglado = unserialize($fix_max['contenido']);
  24.  
  25. for ($i = 0; $i < count($arreglado); $i++)
  26.  
  27. {
  28. $asd= "select nombre, precio from productos where id = ".(int)$arreglado[$i].";";
  29. $dsa = mysql_query($asd, $conexionproductos) or die(mysql_error());
  30. $fix = mysql_fetch_assoc($dsa);
  31. $total += $fix['precio'];
  32. $html=$html. '<tr><td><center>'.$fix['nombre'].'</center></td>';
  33. $html=$html. '<td><center>'.$fix['precio'].'</center></td></tr>';
  34. }
  35.  
  36.  
  37. } while ($fix_max = mysql_fetch_assoc($max_exec));
  38. }
  39.  
  40. $html=$html. '<tr><td><center>TOTAL</center></td><td><center>'.$total.'</center></td></tr></table>';
  41.  
  42. $html=utf8_decode($html);
  43. $dompdf = new DOMPDF();
  44. $dompdf->load_html($html);
  45. $dompdf->render();
  46. $dompdf->stream("factura.pdf");

espero puedan ayudarme a arreglar ese molesto problema  :-\
 un saludo y gracias de antemano   :xD


Título: Re: Unable to stream pdf: headers already sent
Publicado por: engel lex en 25 Junio 2013, 20:39 pm
revisa que ninguna parte de tu codigo haya hecho salida... ese mensaje es que ya envió informacion al navegador...

puede ser que tienes alguna parte de html estática, que tienes algún echo o print o que hay espacios en blnco que el navegador está asumiendo luego de la etiqueta ?> (puedes quitar esa etiqueta para probar, la sintaxis de php lo permite http://www.php.net/manual/en/language.basic-syntax.instruction-separation.php (http://www.php.net/manual/en/language.basic-syntax.instruction-separation.php))


Título: Re: Unable to stream pdf: headers already sent
Publicado por: Legnak en 27 Junio 2013, 21:22 pm
antes de eso estaba mandando un código html XD

gracias por tu ayuda