开发者

outputting table using fpdf

开发者 https://www.devze.com 2023-03-19 12:51 出处:网络
I am trying to output a table using FPDF and PHP. What I need is to output the table headings and I have a doctrine (symfony) collection.

I am trying to output a table using FPDF and PHP.

What I need is to output the table headings and I have a doctrine (symfony) collection.

I'm using the writeHTML method using:

$pdf->writeHTML('<table>','','','','');
$pdf->writeHTML('<tr><th>Tooth Selection</th><th>Requirements</th><th>Shade</th><th>Cost</th></tr>','','','','');
$order_items = $this->order_details->getIncludedItemsOrders();
  foreach($order_items as $item)
  {
    $pdf->writeHTML('<tr><td>Test1</td><开发者_如何转开发td>Test2</td><td>Test3</td><td>test4</td></tr>', '','');
  }

 $pdf->writeHTML('</table>');

But I get errors, such as:

 Notice: Undefined index: cols in
 Notice: Undefined variable: cellspacingx in 

Am I doing this correct as I can't find much information regarding outputting tables using a foreach

Thank


That's FPDF for you. It's full of code that raises E_NOTICE errors. If you need to stay with FPDF, you need to turn E_NOTICE off.

error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT);

I'd recommend moving to a newer and better amintained library like TCPDF though.


I agree with the upper comment. Either disable the errors or even better... FIX them. If some content is already generated you will not be able to set the pdf headers. Though you can still save the pdf to a file.

I have my own fpdf table script: http://interpid.eu/fpdf-table

0

精彩评论

暂无评论...
验证码 换一张
取 消