Ver Mensaje Individual
  #1 (permalink)  
Antiguo 16/09/2020, 01:27
mensajeescrito
 
Fecha de Ingreso: mayo-2012
Mensajes: 760
Antigüedad: 11 años, 11 meses
Puntos: 5
Implementar codigo html en esta tabla fpdf

Hola amigas/os, a ver si me pueden ayudar con esto.
Tengo una tabla que se genera con fpdf.

Pero no se como implementarle para que me interprete codigo html.
Para poner algunas palabras en negrita y cosas así.

Miren mi código es el siguente:

Código PHP:
Ver original
  1. require('../libreria_fpdf/WriteHTML.php');
  2.  
  3.  
  4.  
  5.     class PDF extends FPDF
  6.  
  7.         {
  8.             function plot_table($widths, $lineheight, $table, $border=1, $aligns=array(), $fills=array(), $links=array())
  9.  
  10.                 {
  11.                     $func = function($text, $c_width)
  12.  
  13.                         {
  14.                             $len=strlen($text);
  15.                             $twidth = $this->GetStringWidth($text);
  16.                             $split = floor($c_width * $len / $twidth);
  17.                             $w_text = explode( "\n", wordwrap( $text, $split, "\n", true));
  18.                             return $w_text;
  19.                         };
  20.  
  21.  
  22.  
  23.                     foreach ($table as $line)
  24.  
  25.                         {
  26.                             $line = array_map($func, $line, $widths);
  27.                             $maxlines = max(array_map("count", $line));
  28.  
  29.                             foreach ($line as $key => $cell)
  30.  
  31.                                 {
  32.                                     $x_axis = $this->getx();
  33.                                     $height = $lineheight * $maxlines / count($cell);
  34.                                     $len = count($line);
  35.                                     $width = (isset($widths[$key]) === TRUE ? $widths[$key] : $widths / count($line));
  36.                                     $align = (isset($aligns[$key]) === TRUE ? $aligns[$key] : '');
  37.                                     $fill = (isset($fills[$key]) === TRUE ? $fills[$key] : false);
  38.                                     $link = (isset($links[$key]) === TRUE ? $links[$key] : '');
  39.  
  40.                                     foreach ($cell as $textline)
  41.  
  42.                                         {
  43.                                             $this->cell($widths[$key],$height,$textline,0,0,$align,$fill,$link);
  44.  
  45.                                             $height += 2 * $lineheight * $maxlines / count($cell);
  46.                                             $this->SetX($x_axis);
  47.                                         }
  48.  
  49.                                     if($key == $len - 1)
  50.  
  51.                                         {
  52.                                             $lbreak=1;
  53.                                         }
  54.  
  55.                                         else
  56.  
  57.                                         {
  58.                                             $lbreak = 0;
  59.                                         }
  60.  
  61.                                     $this->cell($widths[$key],$lineheight * $maxlines, '',$border,$lbreak);
  62.                                 }
  63.                         }
  64.                 }
  65.         }
  66.  
  67.  
  68.  
  69.     $pdf = new PDF('P','mm','A4');
  70.  
  71.     $lineheight = 6;
  72.  
  73.     $fontsize = 8;
  74.  
  75.     $pdf->SetAutoPageBreak(true , 10);
  76.     $pdf->SetMargins(20, 1, 20);
  77.  
  78.     $pdf->AddPage();
  79.  
  80.  
  81.    $pdf->AddFont('arial','','arial.php');
  82.  
  83.     $pdf->SetFont('arial', '', 7);
  84.  
  85.  
  86.  
  87.     $table = array(array(utf8_decode('texto 1'), utf8_decode('texto 2'), utf8_decode('texto 3')), array(utf8_decode('texto 4'), utf8_decode('texto 5'), utf8_decode('texto 6')), array('texto 7', utf8_decode('texto 8'), utf8_decode('texto 9')), array('texto 10', utf8_decode('texto 11'), utf8_decode('texto 12')), array('texto 13', utf8_decode('texto 14'), utf8_decode('texto 15')));
  88.  
  89.     $widths = array(30,75,75);
  90.  
  91.  
  92.  
  93.     $pdf->plot_table($widths, $lineheight, $table);
  94.  
  95.  
  96.  
  97.     $pdf->Output('Table.pdf', 'I');
  98.  
  99.     return;

Imagino que debería implementar : "$fpdf->WriteHTML($texto)", para conseguir que me interprete codigo html. pero no consigo saber como implementar esto.

Si me pudieran ayudar les estaría muy agradecido.