TCPDF - Как отображать заголовки таблиц на каждой странице данных таблицы? - PullRequest
1 голос
/ 03 июля 2010

All

Я пытаюсь отобразить таблицу со страницами и страницами данных. Рендеринг терпит неудачу полностью, начиная со второй страницы. Кроме того, как я могу убедиться, что таблица, которая распространяется на страницы и страницы, имеет заголовки таблицы на каждой странице?

Это функция, которую я использую до сих пор, но, кажется, она не очень хорошо работает со второй страницы:

Спасибо

// Colored table
public function ColoredTable($header,$data) {
    // Colors, line width and bold font
    $this->SetFillColor(170,195,255);
    $this->SetTextColor(0);
    $this->SetDrawColor(205, 205, 205);
    $this->SetLineWidth(0.3);
    $this->SetFont('helvetica', 'B');
    // Header
    $w = array(35, 35, 20, 20, 20, 10, 20, 8, 20);
    $num_headers = count($header);
    for($i = 0; $i < $num_headers; ++$i) {
        $this->Cell($w[$i], 7, $header[$i], 1, 0, 'C', 1);
    }
    $this->Ln();
    // Color and font restoration
    $this->SetFillColor(225, 229, 233);
    $this->SetTextColor(0);
    $this->SetFont('helvetica','','10');
    // Data
    $fill = 0;
    foreach($data as $row) {

        $this->MultiCell($w[0], 8, $row[0], 1, 'L', $fill, 0, '', '', true, 0, false, true, 8, 'M', true);
        $this->MultiCell($w[1], 8, $row[1], 1, 'L', $fill, 0, '', '', true, 0, false, true, 8, 'M', true);
        $this->MultiCell($w[2], 5, $row[2], 1, 'L', $fill, 0, '', '', true, 0, false, true, 10, 'M', true);
        $this->MultiCell($w[3], 5, $row[3], 1, 'L', $fill, 0, '', '', true, 0, false, true, 10, 'M', true);
        $this->MultiCell($w[4], 8, $row[4], 1, 'L', $fill, 0, '', '', true, 0, false, true, 8, 'M', true);
        $this->MultiCell($w[5], 5, $row[5], 1, 'L', $fill, 0, '', '', true, 0, false, true, 10, 'M', true);
        $this->MultiCell($w[6], 8, $row[6], 1, 'L', $fill, 0, '', '', true, 0, false, true, 8, 'M', true);
        $this->MultiCell($w[7], 5, $row[7], 1, 'L', $fill, 0, '', '', true, 0, false, true, 10, 'M', true);
        $this->MultiCell($w[8], 8, $row[8], 1, 'L', $fill, 0, '', '', true, 0, false, true, 8, 'M', true);
        $this->Ln();
        $fill=!$fill;
    }
    $this->Cell(array_sum($w), 0, '', 'T');
}

1 Ответ

0 голосов
/ 22 декабря 2010

Может работать следующий код:

$pdf->SetHeaderData(PDF_HEADER_LOGO, 300, "", PDF_HEADER_STRING);
...