【问题标题】:Trying to display headers on multiple pages with FPDF尝试使用 FPDF 在多个页面上显示标题
【发布时间】:2013-12-22 20:33:22
【问题描述】:

我正在使用 FPDF 从 Mysql 数据库创建报告。 PDF 创建得很好,但我想在每一页的顶部显示每一列的标题,以便于导航。有谁知道如何做到这一点?

感谢您的帮助。

【问题讨论】:

    标签: php fpdf


    【解决方案1】:

    尝试扩展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();
    

    【讨论】:

      猜你喜欢
      • 2014-01-05
      • 2014-03-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-01-14
      • 1970-01-01
      • 2017-08-13
      相关资源
      最近更新 更多