TCPDF: rendering an HTML table

Is it possible to display an HTML table in PDF using TCPDF scalable on the page? Because I have a lot of them. there are so many columns in my table .. like some kind of zooming scale ... Is it possible, maybe ... but I don't know how ..

enter image description here

+6
source share
3 answers

TCPDF allows you to write HTML in such a way that your table structure does not matter. example

 $tbl = <<<EOD <table border="1"> <tr> <th rowspan="3">Left column</th> <th colspan="5">Heading Column Span 5</th> <th colspan="9">Heading Column Span 9</th> </tr> <tr> <th rowspan="2">Rowspan 2<br />This is some text that fills the table cell.</th> <th colspan="2">span 2</th> <th colspan="2">span 2</th> <th rowspan="2">2 rows</th> <th colspan="8">Colspan 8</th> </tr> <tr> <th>1a</th> <th>2a</th> <th>1b</th> <th>2b</th> <th>1</th> <th>2</th> <th>3</th> <th>4</th> <th>5</th> <th>6</th> <th>7</th> <th>8</th> </tr> </table> EOD; $pdf->writeHTML($tbl, true, false, false, false, ''); 

See full full code | See PDF output

+2
source

Submit page settings to avoid this. Set an array variable with width and height like this.

 $pageDimension = array('500,300'); //width,height 

Replace this value with the array in which you are using this predefined TCPDF variable ( PDF_PAGE_FORMAT )

Replace PDF_PAGE_FORMAT with $pageDimension

+1
source

You do not need to specify a column width table to get the desired results, but there will be a lot of wrapping depending on your content. I think the best way is to choose a different page type, such as A3, not A4 and terrain.

0
source

All Articles