【问题标题】:FPDF isnt adding new pageFPDF 不添加新页面
【发布时间】:2012-03-11 11:28:50
【问题描述】:

这是我的代码的 sn-p,当它们在数组中为 1 值时,我试图在其中生成 pdf,例如

"$arrIds = array('10'); ". 

我的代码生成 pdf,但是当数组中有更多值时,我无法看到下一页。

  function action_pdf_reportPt10()
{
    $arrIds = array('10', '5', '12', '31');
    foreach ($arrIds as $id)
    {
        $this->_Pt10_Calculations->setPropertyId($id);
        $this->_FpdfGenerator = new Fpdf('L');
        $pt10values = $this->_Pt10_Calculations->fetch_record_by_property_id();


        $this->generate_pt10($pt10values);

    }

    $this->load->view('admin/property/report_pt10', $this->view_data);
}

还有

 public function generate_pt10($pt10values)
{
    $tax_amount = round(@$pt10values[0]['tax_amount']);

    $self_rented = @$pt10values[0]['self_rent'];
    switch ($self_rented)
    {
        case '1':
            $self_rented = 'Self';
            break;
        case '2':
            $self_rented = 'Rented';
            break;
        case '3':
            $self_rented = '1)Self 2)Rented';
            break;
    }

    $location = @$pt10values[0]['location'];
    switch ($location)
    {
        case '1':
            $location = 'Main Road';
            break;
        case '2':
            $location = 'Off Road';
            break;
    }


    $baseXcoordinate = 5;

    $this->_FpdfGenerator->AddPage();
    $this->_FpdfGenerator->AliasNbPages();
    $this->_FpdfGenerator->SetXY($baseXcoordinate, 10);
    $this->_FpdfGenerator->SetFont('Arial', 'B', 5);
    $this->_FpdfGenerator->MultiCell(13, 7, 'Rating Area', 1);
    $this->_FpdfGenerator->SetXY(18, 10);
    $this->_FpdfGenerator->SetFont('Arial', 'B', 6);
    $this->_FpdfGenerator->MultiCell(15, 7, 'Zone', 1);
    $this->_FpdfGenerator->SetXY(33, 10);
    $this->_FpdfGenerator->SetFont('Arial', 'B', 5);
    $this->_FpdfGenerator->MultiCell(25, 7, 'Area', 1);
    $this->_FpdfGenerator->SetXY($baseXcoordinate, 24);
    $this->_FpdfGenerator->SetFont('Arial', 'B', 7);
    $this->_FpdfGenerator->MultiCell(28, 9, 'Property No', 1);
    $this->_FpdfGenerator->SetXY($baseXcoordinate, 33);
    $this->_FpdfGenerator->SetFont('Arial', 'B', 7);
    $this->_FpdfGenerator->MultiCell(28, 9, 'Pin', 1);
    $this->_FpdfGenerator->SetXY(58, 10);
    $this->_FpdfGenerator->SetFont('Arial', 'B', 6);
    $this->_FpdfGenerator->MultiCell(20, 7, 'Issue Date', 1);
    $this->_FpdfGenerator->SetXY(78, 10);
    $this->_FpdfGenerator->SetFont('Arial', 'B', 6);
    $this->_FpdfGenerator->MultiCell(25, 7, 'Due Date For Payment', 1);
    $this->_FpdfGenerator->SetXY(89.5, 10);
    $this->_FpdfGenerator->ln();
    $this->_FpdfGenerator->Output();
   }

我不知道我缺少什么,因为数组中的单个值工作正常。但是当数组中有更多的值时,它不会添加页面。

【问题讨论】:

    标签: php fpdf


    【解决方案1】:

    $this->_FpdfGenerator->Output(); 终止文档 here 是 doc,所以如果有一些数据要添加,你不应该调用它

    【讨论】:

    • 函数 action_pdf_reportPt10() { $arrIds = array('10', '5', '12', '31'); foreach ($arrIds as $id) { $this->_Pt10_Calculations->setPropertyId($id); $this->_FpdfGenerator = new Fpdf('L'); $pt10values = $this->_Pt10_Calculations->fetch_record_by_property_id(); $this->generate_pt10($pt10values); $this->_FpdfGenerator->Output(); $this->load->view('admin/property/report_pt10', $this->view_data); }
    • thx 伙计,我实际上做了一些小改动,它为我节省了很多,我采用了循环的构造函数并尝试了你所说的,它可以工作,thx 伙计。上帝保佑你。
    • 不客气。我错过了构造函数也在循环内:这并不正确。
    猜你喜欢
    • 2014-06-05
    • 2015-05-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-07-03
    • 2018-05-01
    • 2014-12-19
    相关资源
    最近更新 更多