2

I'm doing a report generator with codeigniter and I'm using tcpdf to create my PDF files.

First I create the table from the query result in codeigniter like this:

$query = $this->db->query($sql);
$html = $this->table->generate($query);

Then I use the html as the PDF content like this:

$pdf->writeHTMLCell($w = 0, $h = 0, $x = '', $y = '', $html, $border = 0, $ln = 1, $fill = 0, $reseth = true, $align = '', $autopadding = true);
$pdf->Output($data['path'] . $data['file_name'] . '.pdf', 'F');

Everything is fine but sometimes the table just won't appear, the rest of the PDF like the header is just fine but the table won't show.

I think is some kind of overflow because the table won't appear when the content inside a row is too long.

I've tried to set the max width of the columns doing this:

.normal_row{
    background-color: #FFFFFF;
    height: 1em;
    max-width: 200px;
}

But it didn't work.

Any ideas on how to fix this problem?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Eliel
  • 109
  • 1
  • 7

2 Answers2

1

I had similar problem with disappearing text inside HTML tables. It probably wasn't same cause as yours but for future reference -- my problem was with letter "š" and font dejavusans. When I switched to freesans, content of my table was drawn correctly.

Martin
  • 1,473
  • 2
  • 12
  • 20
0

As I too recently discovered, TCPDF does not carry all of the standard css functions. It does not inherent CSS functions each one has to be programmed in (i.e. padding, margin, etc.) and defiantly does not hand em definitions. You are going to have to keep it old school as possible and use the least amount of CSS possible. Also take a look at this: related post.

It can be done as I found out but it is not easy, I think that with the current coding style TCPDF really needs a overhaul where CSS is concerned especially with mid-level CSS functions.

I hope I at least saved you hours of searching and testing really you need to find the functions TCPDF will do and try to fit those to your need for now. TCPDF is still an outstanding library it just needs to be updated.

Community
  • 1
  • 1
BrandonS
  • 932
  • 7
  • 16
  • I deleted all the CSS and the problem persist, the problem seems to be related to memory overflow or something like that because when I output less data the table is drawn perfectly. Thanks though! – Eliel Jan 30 '12 at 21:43