【发布时间】:2013-12-22 20:33:22
【问题描述】:
我正在使用 FPDF 从 Mysql 数据库创建报告。 PDF 创建得很好,但我想在每一页的顶部显示每一列的标题,以便于导航。有谁知道如何做到这一点?
感谢您的帮助。
【问题讨论】:
我正在使用 FPDF 从 Mysql 数据库创建报告。 PDF 创建得很好,但我想在每一页的顶部显示每一列的标题,以便于导航。有谁知道如何做到这一点?
感谢您的帮助。
【问题讨论】:
尝试扩展fpdf类,实现你的Ln函数:每增加一行,行号递减计数器,当为0时,增加新页头。
class _PDF extends FPDF
{
var $_num_Rows = null;
var $_heightCell = null;
const NUM_ROWS = 48; // set number line in page
function _PDF($orientation = 'P',$unit = 'mm' ,$page = 'A4')
{
$this->_numRows = self::NUM_ROWS;
$this->_heightCell = 4;
$this->SetAutoPageBreak(true,10);
$this->FPDF($orientation, $unit, $page);
}
public function init_numRows()
{
$this->_numRows = self::NUM_ROWS;
}
public function dec_numRows()
{
$this->_numRows--;
}
function Ln()
{
if ( $this->_numRows )
{
parent::Ln();
$this->dec_numRows();
}
else
{
$this->addHeader();
}
}
function addHeader()
{
$this->init_numRows();
$this->AddPage();
// ...
}
}
$pdf = new _PDF();
【讨论】: