我已经使用fpdf库创建了这个表。现在我想在table.so中设置页眉和页脚,查看屏幕截图了解更多详细信息。我想显示公司的名称和接收者的名称,并在页眉中显示更多详细信息。

// Colored table
private function FancyTable($header, $data) {
// Colors, line width and bold font
$this->fpdf->SetFillColor(255, 0, 0);
$this->fpdf->SetTextColor(255);
$this->fpdf->SetDrawColor(128, 0, 0);
$this->fpdf->SetLineWidth(.1);
$this->fpdf->SetFont('', '', 1);
// Header
$w = array(20, 100, 20, 20, 30);
for ($i = 0; $i < count($header); $i++) {
$this->fpdf->Cell($w[$i], 7, $header[$i], 1, 0, 'C', true);
}
$this->fpdf->Ln();
// Color and font restoration
$this->fpdf->SetFillColor(224, 235, 255);
$this->fpdf->SetTextColor(0);
$this->fpdf->SetFont('', '', 10);
// Data
$fill = false;
$this->data_array = array();
$this->getdata($data, 0);
foreach ($this->data_array as $row) {
if (strlen($row[1]) > 50) {
$this->fpdf->Cell($w[0], 5, $row[0], 'LR', 0, 'L', $fill);
$this->fpdf->Cell($w[1], 5, substr($row[1], 0, 50), 'LR', 0, 'L', $fill);
$this->fpdf->Cell($w[2], 5, $row[2], 'LR', 0, 'L', $fill);
$this->fpdf->Cell($w[3], 5, $row[3], 'LR', 0, 'L', $fill);
$this->fpdf->Cell($w[4], 5, $row[4], 'LR', 0, 'L', $fill);
$this->fpdf->Ln();
$this->fpdf->Cell($w[0], 5, $row[0] = '', 'LR', 0, 'L', $fill);
$this->fpdf->Cell($w[1], 5, substr($row[1], 50), 'LR', 0, 'L', $fill);
$this->fpdf->Cell($w[2], 5, $row[2] = '', 'LR', 0, 'L', $fill);
$this->fpdf->Cell($w[3], 5, $row[3] = '', 'LR', 0, 'L', $fill);
$this->fpdf->Cell($w[4], 5, $row[4] = '', 'LR', 0, 'L', $fill);
$this->fpdf->Ln();
$fill = !$fill;
} else {
$this->fpdf->Cell($w[0], 5, $row[0], 'LR', 0, 'L', $fill);
$this->fpdf->Cell($w[1], 5, $row[1], 'LR', 0, 'L', $fill);
$this->fpdf->Cell($w[2], 5, $row[2], 'LR', 0, 'L', $fill);
$this->fpdf->Cell($w[3], 5, $row[3], 'LR', 0, 'L', $fill);
$this->fpdf->Cell($w[4], 5, $row[4], 'LR', 0, 'L', $fill);
$this->fpdf->Ln();
$fill = !$fill;
}
}
// Closing line
$this->fpdf->Cell(array_sum($w), 0, '', 'T');
}发布于 2016-02-06 12:15:22
https://stackoverflow.com/questions/35237192
复制相似问题