1

Al momento de generar mi pdf solo genera los datos pero no aplica los estilos de la tabla en si. El CSS estan externamente, ya hice la prueba de poner el CSS junto al HTML en el Head pero no ha funcionado.

/Spam para que no me salte la alerta de añadir mas detalles ya que son los unicos detalles que tengo. Spam para que no me salte la alerta de añadir mas detalles ya que son los unicos detalles que tengo. Spam para que no me salte la alerta de añadir mas detalles ya que son los unicos detalles que tengo./

Foto de como me queda la tabla sin los estilos.

Este es mi código.

<?php
ob_start();
?>

   <!DOCTYPE html>
   <html lang="en">
   <head>
       <meta charset="UTF-8">
       <meta http-equiv="X-UA-Compatible" content="IE=edge">
       <meta name="viewport" content="width=device-width, initial-scale=1.0">
       <link rel="stylesheet" type="text/css" href="styles/styleTable.css">
       <title>Document</title>
   </head>
   <body>
    <div id="wrapper">
     <h1>Registro De Alumnos</h1>
     
     <table id="keywords" cellspacing="0" cellpadding="0">
       <thead>
         <tr>
           <th><span>Nombres y Apellidos</span></th>
           <th><span>Cedula</span></th>
           <th><span>Cod. Matricula</span></th>
           <th><span>Telefono</span></th>
           <th><span>Correo</span></th>
           <th><span>Direccion</span></th>
           <!--Se puede segui aunmentando aqui las columnas :D-->
         </tr>
       </thead>

       <?php 
       include("conexion.php");
       $objConexion = new Conexion();
       $con = $objConexion->conectar();       
       $estudiante = "SELECT * FROM estudiante";

       if(isset($_POST['btn1'])){

       $resultado = mysqli_query($con,$estudiante);
       while($consulta = mysqli_fetch_array($resultado)){
       ?>

       <tbody>
         <tr>
           <td class="lalign"> <?php echo $consulta['NombresApellidos'];?> </td>
           <td><?php echo $consulta['Cedula'];?> </td>
           <td><?php echo $consulta['CodigoMatricula'];?> </td>
           <td><?php echo $consulta['Telefono'];?> </td>
           <td><?php echo $consulta['Correo'];?> </td>
           <td><?php echo $consulta['Direccion'];?> </td>
       </tbody>
       <?php
            } 
         }?>
     </table>
    </div> 
   </body>  
   </body>
   </html>
<?php
$html=ob_get_clean();
//echo $html;


require_once 'lib/dompdf/autoload.inc.php';

use Dompdf\Dompdf;

$dompdf = new Dompdf();



$options = $dompdf->getOptions();     
$options->set(array('isRemoteEnabled' => true));
$dompdf->setOptions($options);
$dompdf->loadHtml($html);
$dompdf->setPaper('letter');
$dompdf->render();
$dompdf->stream("nombre_.pdf", array("Attachment" => false)); //Para ver el archivo en el navegador.


?>

Codigo CSS

@import url('https://fonts.googleapis.com/css?family=Amarante');

html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i, center, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, article, aside, canvas, details, embed, figure, figcaption, footer, header, hgroup, menu, nav, output, ruby, section, summary, time, mark, audio, video {
  margin: 0;
  padding: 0;
  border: 0;
  font-size: 100%;
  font: inherit;
  vertical-align: baseline;
  outline: none;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  -ms-text-size-adjust: 100%;
  -webkit-box-sizing: border-box;
  -moz-box-sizing: border-box;
  box-sizing: border-box;
}
html { overflow-y: scroll; }
body { 
  background: #eee url('https://i.imgur.com/eeQeRmk.png'); /* https://subtlepatterns.com/weave/ */
  font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
  font-size: 62.5%;
  line-height: 1;
  color: #585858;
  padding: 22px 10px;
  padding-bottom: 55px;
}

::selection { background: #5f74a0; color: #fff; }
::-moz-selection { background: #5f74a0; color: #fff; }
::-webkit-selection { background: #5f74a0; color: #fff; }

br { display: block; line-height: 1.6em; } 

article, aside, details, figcaption, figure, footer, header, hgroup, menu, nav, section { display: block; }
ol, ul { list-style: none; }

input, textarea { 
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  -ms-text-size-adjust: 100%;
  -webkit-box-sizing: border-box;
  -moz-box-sizing: border-box;
  box-sizing: border-box;
  outline: none; 
}

blockquote, q { quotes: none; }
blockquote:before, blockquote:after, q:before, q:after { content: ''; content: none; }
strong, b { font-weight: bold; } 

table { border-collapse: collapse; border-spacing: 0; }
img { border: 0; max-width: 100%; }

h1 { 
  font-family: 'Amarante', Tahoma, sans-serif;
  font-weight: bold;
  font-size: 3.6em;
  line-height: 1.7em;
  margin-bottom: 10px;
  text-align: center;
}


/** page structure **/
#wrapper {
  display: block;
  width: 950px;
  background: #fff;
  margin: 0 auto;
  padding: 10px 17px;
  -webkit-box-shadow: 2px 2px 3px -1px rgba(0,0,0,0.35);
}

#keywords {
  margin: 0 auto;
  font-size: 1.2em;
  margin-bottom: 15px;
}


#keywords thead {
  cursor: pointer;
  background: #c9dff0;
}
#keywords thead tr th { 
  font-weight: bold;
  padding: 12px 30px;
  padding-left: 42px;
}
#keywords thead tr th span { 
  padding-right: 20px;
  background-repeat: no-repeat;
  background-position: 100% 100%;
}

#keywords thead tr th.headerSortUp, #keywords thead tr th.headerSortDown {
  background: #acc8dd;
}

#keywords thead tr th.headerSortUp span {
  background-image: url('https://i.imgur.com/SP99ZPJ.png');
}
#keywords thead tr th.headerSortDown span {
  background-image: url('https://i.imgur.com/RkA9MBo.png');
}


#keywords tbody tr { 
  color: #555;
}
#keywords tbody tr td {
  text-align: center;
  padding: 15px 10px;
}
#keywords tbody tr td.lalign {
  text-align: left;
}
3
  • ¿Donde está el css styles/styleTable.css? ¿Lo puedes agregar a la pregunta?
    – masterguru
    el 22 ene. 2022 a las 21:49
  • Ya lo agregue :D
    – Charlie
    el 22 ene. 2022 a las 22:23
  • Amigo, pudiste resolverlo de alguna forma? Presento el mismo error el 3 ago. 2022 a las 3:34

0

Tu Respuesta

By clicking “Publica tu respuesta”, you agree to our terms of service and acknowledge you have read our privacy policy.

Examina otras preguntas con la etiqueta o formula tu propia pregunta.