簡體   English   中英

使用TCPDF時出錯

[英]Error Using TCPDF

我正在嘗試將TCPDF與laravel 4配合使用,當我用mysql數據填充表時出現此錯誤,當我使用foreach循環時,它會失敗,如果刪除它,它將可以正常工作:

class PrintController extends BaseController {   

    public function index()
    {
        return View::make('print.PrintView');
    }

    public function generatePDF()
    {
        $notas_detalle = NotaDetalle::all();
        $pdf = $pdf = new TCPDF();
        $pdf->SetPrintHeader(false);
        $pdf->SetPrintFooter(false);
        $pdf->AddPage();
        $html = 
        '<table border="1" cellpadding="4" cellspacing="0" align="center">
        <thead>
         <tr>
          <th colspan="4">
            <p>Chapincar S.R.L</p>
            <p>Agustin Barios Nº 1070 c/ Julio C. Franco - Telefono 674 942 <br/>   
            Fernando de la Mora - Paraguay</p>
            <p></p>
          </th>
          <th colspan="2">
            <p>RUC:80029658-3</p>
            <p>NOTA DE PRESUPUESTO</p>
          </th>
         </tr>
         <tr>
          <td colspan="6" align="left">Asuncion, 26 de Noviembre de 2014</td>
         </tr>
         <tr>
          <td colspan="6" align="left">Señores: Aseguradora del Este</td>
         </tr>
         <tr>
          <td colspan="6" align="left">Dirección: Gilberto Aranda 231</td>
         </tr>
         <tr>
          <td colspan="2" align="left">Telefono: 021674611</td>
          <td colspan="4" align="left">Fecha: 20/12/2014</td>
        </tr>
        </thead>
        <tbody>
         <tr>
          <td>Cantidad</td>
          <td colspan="3">Descripción</td>
          <td>Precio con IVA</td>
          <td>Precio sin IVA</td>
         </tr>';

        $html .= '<tr>';

// HERE IT'S THE ERROR
        foreach ($notas_detalle as $key => $value) {
             $html .= '<td>' .  $value->cantidad_detalle . '</td>';
             $html .= '<td colspan="3">' .  $value->descripcion_detalle . '</td>';
             $html .= '<td>' .   $value->precioIVA_detalle . '</td>';
             $html .= '<td>' .   $value->precioSinIVA_detalle . '</td>';
        }

// ERROR

        $html .= '</tr>';

        $html .= 
        '</tbody>
        </table>'
         ;

        $pdf->writeHTML($html, true, false, true, false, '');
        //$pdf->Text(90, 140, 'This is a test');
        $filename = storage_path() . '/test.pdf';
        $pdf->output($filename, 'I');

        //return Response::download($filename);
    }

}

我做錯了什么? 請幫忙。

評論中提供了解決方案。 如果有人遇到類似問題,請在此處提供:

$html .= '<tr>';

$html .= '</tr>';

需要在foreach循環內

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM