PHP - error en descarga pdf

 
Vista:
Imágen de perfil de VICTOR AUGUSTO
Val: 13
Ha aumentado su posición en 15 puestos en PHP (en relación al último mes)
Gráfica de PHP

error en descarga pdf

Publicado por VICTOR AUGUSTO (9 intervenciones) el 19/06/2018 18:04:55
hola gracias por sus consejos pero tengo este problema cuando exporto el archivo lo descarga pero al abrirlo me sale que el archivo esta dañado y que hubo un error en la descarga este mi codigo

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php
    require_once("dompdf/dompdf_config.inc.php");
    $conexion=mysqli_connect('localhost', 'root', '', 'usuarios');
$codigoHTML.='
<html lang="en">
  <head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <title>REPORTE</title>
  </head>
  <body>
    <h1>REPORTE</h1>
    <table cellpadding="12px" cellspacing="0px" border="1" align="center" >
        <tr>
          <td align="center" bgcolor="#1D90EB" width="33.33%">id</td>
          <td align="center" bgcolor="#1D90EB" width="33.33%">Nombre</td>
          <td align="center" bgcolor="#1D90EB" width="33.33%">Apellido</td>
          <td align="center" bgcolor="#1D90EB" width="33.33%">Correo</td>
          <td align="center" bgcolor="#1D90EB" width="33.33%">Usuario</td>
          <td align="center" bgcolor="#1D90EB" width="33.33%">Password</td>
          <td align="center" bgcolor="#1D90EB" width="33.33%">Tipo de Usuario</td>
        </tr>';
          $sql="SELECT * FROM usuarios_bd";
          $result=mysqli_query($conexion,$sql);
        while($mostrar=mysqli_fetch_array($result)){
        $codigoHTML.='
        <tr>
          <td>'.$mostrar['id'].'</td>
          <td>'.$mostrar['Nombre'].'</td>
          <td>'.$mostrar['Apellido'].'</td>
          <td>'.$mostrar['Correo'].'</td>
          <td>'.$mostrar['Usuario'].'</td>
          <td>'.$mostrar['Password'].'</td>
          <td>'.$mostrar['Tipo'].'</td>
        </tr>';
         }
      $codigoHTML='
    </table>
  </body>
</html>';
$codigoHTML=utf8_encode($codigoHTML);
$dompdf=new DOMPDF();
$dompdf->load_html($codigoHTML);
ini_set("memory_limit","128M");
$dompdf->set_paper('A4', 'landscape');
$dompdf->render();
$dompdf->stream("Reporte_1.pdf");
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
sin imagen de perfil
Val: 127
Ha mantenido su posición en PHP (en relación al último mes)
Gráfica de PHP

error en descarga pdf

Publicado por Rrazo (55 intervenciones) el 19/06/2018 19:01:52
Nuevamente estas reemplazando el valor de la variable $codigoHTML

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// Primero debes darle un valor...
$codigoHTML ='             //  antes  $codigoHTML .='     ahora    // $codigoHTML ='
<html lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>REPORTE</title>
</head>
<body>
<h1>REPORTE</h1>
<table cellpadding="12px" cellspacing="0px" border="1" align="center" >
<tr>
<td align="center" bgcolor="#1D90EB" width="33.33%">id</td>
<td align="center" bgcolor="#1D90EB" width="33.33%">Nombre</td>
<td align="center" bgcolor="#1D90EB" width="33.33%">Apellido</td>
<td align="center" bgcolor="#1D90EB" width="33.33%">Correo</td>
<td align="center" bgcolor="#1D90EB" width="33.33%">Usuario</td>
<td align="center" bgcolor="#1D90EB" width="33.33%">Password</td>
<td align="center" bgcolor="#1D90EB" width="33.33%">Tipo de Usuario</td>
</tr>';
$sql="SELECT * FROM usuarios_bd";
$result=mysqli_query($conexion,$sql);
while($mostrar=mysqli_fetch_array($result)){
$codigoHTML.='
<tr>
<td>'.$mostrar['id'].'</td>
<td>'.$mostrar['Nombre'].'</td>
<td>'.$mostrar['Apellido'].'</td>
<td>'.$mostrar['Correo'].'</td>
<td>'.$mostrar['Usuario'].'</td>
<td>'.$mostrar['Password'].'</td>
<td>'.$mostrar['Tipo'].'</td>
</tr>';
}
$codigoHTML .='                 //  antes  $codigoHTML ='     ahora    // $codigoHTML .='   es aqui donde seguias reemplazando el valor
</table>
</body>
</html>';
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar
Imágen de perfil de VICTOR AUGUSTO
Val: 13
Ha aumentado su posición en 15 puestos en PHP (en relación al último mes)
Gráfica de PHP

error en descarga pdf

Publicado por VICTOR AUGUSTO (9 intervenciones) el 19/06/2018 20:48:17
podrias explicarte mejor disculpa es que soy nuevo en php
Fatal error: Uncaught DOMPDF_Exception: No block-level parent found. Not good. in C:\xampp\htdocs\php-IniciarSesion\dompdf\include\inline_positioner.cls.php:38 Stack trace: #0 C:\xampp\htdocs\php-IniciarSesion\dompdf\include\frame_decorator.cls.php(546): Inline_Positioner->position() #1 C:\xampp\htdocs\php-IniciarSesion\dompdf\include\text_frame_reflower.cls.php(331): Frame_Decorator->position() #2 C:\xampp\htdocs\php-IniciarSesion\dompdf\include\frame_decorator.cls.php(556): Text_Frame_Reflower->reflow(NULL) #3 C:\xampp\htdocs\php-IniciarSesion\dompdf\include\page_frame_reflower.cls.php(138): Frame_Decorator->reflow() #4 C:\xampp\htdocs\php-IniciarSesion\dompdf\include\frame_decorator.cls.php(556): Page_Frame_Reflower->reflow(NULL) #5 C:\xampp\htdocs\php-IniciarSesion\dompdf\include\dompdf.cls.php(817): Frame_Decorator->reflow() #6 C:\xampp\htdocs\php-IniciarSesion\reporte_pdf.php(45): DOMPDF->render() #7 {main} thrown in C:\xampp\htdocs\php-IniciarSesion\dompdf\include\inline_positioner.cls.php on line 38
me sale este error
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar
sin imagen de perfil
Val: 127
Ha mantenido su posición en PHP (en relación al último mes)
Gráfica de PHP

error en descarga pdf

Publicado por Rrazo (55 intervenciones) el 20/06/2018 04:13:37
Esa librería que estas usando suele no estar tan completa en atributos html, Si ya hiciste los cambios que te mencioné antes, debería funcionar, si no, habrá que ver que linea html es la que esta fallando, igual y pon el código y vemos que mas puede estar pasando.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar
Imágen de perfil de VICTOR AUGUSTO
Val: 13
Ha aumentado su posición en 15 puestos en PHP (en relación al último mes)
Gráfica de PHP

error en descarga pdf

Publicado por VICTOR AUGUSTO (9 intervenciones) el 20/06/2018 08:48:20
holas muchas gracias ya lo resolvi era simplemente juntar el codigo estaba dejando muchos espacios
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar