FPDF标题导致第二页上的第二列断开到第三页

时间:2017-03-14 16:33:32

标签: fpdf

我有一个标题,由2个单元格组成,一个在另一个上方延伸,大约四分之一宽度对齐到左边,另外两个单元格在页面宽度上延伸,文本右对齐和边框底部。

然后我在两列中有文本行,其中所有行可以扩展三页或更多页,显然需要在每页上打印一个标题。每行包含两个MultiCell。当我不打印标题时,两列文本打印正常。但是,当我打印标题时,第二页上第一行的右列不会打印到第三页,然后行和列在第三页上打印正常,只有一个左单元格打印在第二页,第二页上打印的左侧单元格从第3页开始丢失。

我似乎无法弄清楚我做错了什么。非常感谢帮助。

这是代码......

require('vendor/fpdf181/fpdf.php');
require('../includes/php/fpdf.class.php');

$pdf = new PDF('P','mm','Letter');

$pdf->AddPage();

$pdf->SetFont('Arial','',12);

$w=50;
$x=$pdf->GetX();
$y=$pdf->GetY();
$pdf->Multicell($w,5,'Created:');
$pdf->SetXY($x+$w,$y);
$w=146;
$nowLocal = convertUTCToLocal($now, $_SESSION['tz_offset_from_utc_in_secs']);
$pdf->Multicell($w,5,$nowLocal);

$w=50;
$x=$pdf->GetX();
$y=$pdf->GetY();
$pdf->Multicell($w,5,'Last Updated:');
$pdf->SetXY($x+$w,$y);
$w=146;
$pdf->Multicell($w,5,$lastUpdated);

$pdf->Ln(5); // linebreak

$w=50;
$x=$pdf->GetX();
$y=$pdf->GetY();
$pdf->Multicell($w,5,'Category:');
$pdf->SetXY($x+$w,$y);
$w=146;
$pdf->Multicell($w,5,$appType);

$w=50;
$x=$pdf->GetX();
$y=$pdf->GetY();
$pdf->Multicell($w,5,'Type:');
$pdf->SetXY($x+$w,$y);
$w=146;
$pdf->Multicell($w,5,$appSubType.' ('.$appSubTypeNotes.')');

$w=50;
$x=$pdf->GetX();
$y=$pdf->GetY();
$pdf->Multicell($w,5,'Meeting Type:');
$pdf->SetXY($x+$w,$y);
$w=146;
$pdf->Multicell($w,5,$meetingType);

$pdf->Ln(5); // linebreak

$w=50;
$x=$pdf->GetX();
$y=$pdf->GetY();
$pdf->Multicell($w,5,'Contact Name:');
$pdf->SetXY($x+$w,$y);
$w=146;
$pdf->Multicell($w,5,$contactName);

$w=50;
$x=$pdf->GetX();
$y=$pdf->GetY();
$pdf->Multicell($w,5,'Contact Phone:');
$pdf->SetXY($x+$w,$y);
$w=146;
$pdf->Multicell($w,5,$contactPhone);

这是fpdf.class.php文件......

<?php

class PDF extends FPDF 
{

    function Header()
    {

    $this->SetFont('Arial','B',20);
    $x=$this->GetX();
    $y=$this->GetY();

    $this->Cell(98,10,'Company Name',0,0);

    $this->SetXY($x,$y+15);
    $this->SetFont('Arial','',16);
    $this->Cell(98,10,'REPORT TITLE',0,0);

    $this->SetXY($x,$y);
    $this->SetFont('Arial','',12);
    $str = <<<END
Address 1
Address 2
Address 3
Phone Number
Fax Number
END;
    $this->MultiCell(196,5,$str,'B','R');

    //$this->SetXY($x,$y+25);

    // Line break
    $this->Ln(10);
    }

    function Footer()
    {
        // Go to 1.5 cm from bottom
        $this->SetY(-15);

        $this->SetFont('Arial','',12);

        // Print centered page number
        $this->Cell(0,10,'Page '.$this->PageNo(),0,0,'C');
    }

}

?>

0 个答案:

没有答案