PHP - Implementar codigo html en esta tabla fpdf

 
Vista:

Implementar codigo html en esta tabla fpdf

Publicado por Sam (185 intervenciones) el 16/09/2020 09:32:09
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:

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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
require('../libreria_fpdf/WriteHTML.php');
 
 
 
class PDF extends FPDF
 
    {
        function plot_table($widths, $lineheight, $table, $border=1, $aligns=array(), $fills=array(), $links=array())
 
            {
                $func = function($text, $c_width)
 
                    {
                        $len=strlen($text);
                        $twidth = $this->GetStringWidth($text);
                        $split = floor($c_width * $len / $twidth);
                        $w_text = explode( "\n", wordwrap( $text, $split, "\n", true));
                        return $w_text;
                    };
 
 
 
                foreach ($table as $line)
 
                    {
                        $line = array_map($func, $line, $widths);
                        $maxlines = max(array_map("count", $line));
 
                        foreach ($line as $key => $cell)
 
                            {
                                $x_axis = $this->getx();
                                $height = $lineheight * $maxlines / count($cell);
                                $len = count($line);
                                $width = (isset($widths[$key]) === TRUE ? $widths[$key] : $widths / count($line));
                                $align = (isset($aligns[$key]) === TRUE ? $aligns[$key] : '');
                                $fill = (isset($fills[$key]) === TRUE ? $fills[$key] : false);
                                $link = (isset($links[$key]) === TRUE ? $links[$key] : '');
 
                                foreach ($cell as $textline)
 
                                    {
                                        $this->cell($widths[$key],$height,$textline,0,0,$align,$fill,$link);
 
                                        $height += 2 * $lineheight * $maxlines / count($cell);
                                        $this->SetX($x_axis);
                                    }
 
                                if($key == $len - 1)
 
                                    {
                                        $lbreak=1;
                                    }
 
                                    else
 
                                    {
                                        $lbreak = 0;
                                    }
 
                                $this->cell($widths[$key],$lineheight * $maxlines, '',$border,$lbreak);
                            }
                    }
            }
    }
 
 
 
$pdf = new PDF('P','mm','A4');
 
$lineheight = 6;
 
$fontsize = 8;
 
$pdf->SetAutoPageBreak(true , 10);
$pdf->SetMargins(20, 1, 20);
 
$pdf->AddPage();
 
 
$pdf->AddFont('arial','','arial.php');
 
$pdf->SetFont('arial', '', 7);
 
 
 
$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')));
 
$widths = array(30,75,75);
 
 
 
$pdf->plot_table($widths, $lineheight, $table);
 
 
 
$pdf->Output('Table.pdf', 'I');
 
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.
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