PHP FPDF固定侧列显示在每个页面标题中,例如

时间:2018-10-10 02:34:36

标签: php fpdf

im正在尝试生成pdf文件。该文件具有页眉和页脚,现在我需要在其中放置一个固定列,在该列中我将显示一些值,并且应该像标题和页脚的行为一样出现在每个页面中

我所做的是尝试将May Header扩展到文档的最低部分,然后将Y设置为页面的开头以与标题重叠,第一页显示正常,但是下一页不。

function Header(){
    $this->AddFont('Century Gothic','B','gothicb.php');
    $this->AddFont('Century Gothic','','century_gothic.php');
    $this->SetFont('Century Gothic','BU',10);

    $this->setDrawColor(189, 195, 199);
    $this->Cell(155,35,'',1,0,'L');
    if($this->PageNo() == 1){
        $this->Image($GLOBALS['imgurl'], $this->GetX(), $this->GetY(), 43,43);
    }
    $this->Cell(45,45,'ssdffds',1,0,'L');
    $this->Ln(35);

    $this->Cell(10,5,'',1,0);
    $this->Cell(98.9,5,$GLOBALS['student'],1,0);
    $this->SetFont('Century Gothic','U',10);
    $this->Cell(20,5,'',1,0);
    $this->Cell(30,5,$GLOBALS['idno'],1,0);
    $this->Ln();
    $this->Cell(20,4,'',1,0);
    $this->Cell(88.9,4,$GLOBALS['address'],1,0);
    $this->Cell(20,4,'',1,0);
    $this->Cell(30,4,$GLOBALS['sex'],1,0);
    $this->Ln();
    $this->Cell(20,4,'',1,0);
    $this->Cell(88.9,4,$GLOBALS['birthplace'],1,0);
    $this->Cell(20,4,'',1,0);
    $this->Cell(30,4,$GLOBALS['dateofbirth'],1,0);
    $this->Ln();
    $this->Cell(20,5,'',1,0);
    $this->Cell(0,5,$GLOBALS['course'],1,0);
    $this->Ln();
    $this->Cell(20,4,'',1,0);
    $this->Cell(88.9,4,$GLOBALS['entrydata'],1,0);
    $this->Cell(35,4,'',1,0);
    $this->Cell(0,6,$GLOBALS['admissiondate'],1,0);
    $this->Ln();
    $this->Cell(40,5,'',1,0);
    $this->Cell(68.9,5,'',1,0);
    $this->Cell(35,6,'',1,0);
    $this->Cell(0,6,'sample',1,0);
    $this->Ln();
    $this->Cell(25,4,'',1,0);
    $this->Cell(0,4,'March 29, 2011',1,0);
    $this->Ln();
    $this->Cell(0,1,'',1,0);
    $this->Ln();
    $this->Cell(30.6,5,'SUBJECT CODE',1,0,'C');
    $this->Cell(100,5,'DESCRIPTIVE TITLE',1,0,'C');
    $this->Cell(12,5,'GRADE',1,0,'C');
    $this->Cell(12,5,'CG',1,0,'C');
    $this->Cell(10,5,'UNITS',1,0,'C');
    $this->Cell(40.3,5,'',1,0,'C');
    $this->Ln();
    for ($i=0; $i <= 40; $i++) { 
        $this->Cell(164.6,5,'',0,0,'C');
        if($i == 23){
            $this->Cell(40.3,5,'display something',1,0,'C');
        }else{
            $this->Cell(40.3,5,'',1,0,'C');
        }

        $this->Ln();
    }

}

这是我的标头代码。下面的示例图片,灰色边框是我的标题,黑色是内容 this is my first page

enter image description here

这是我的内容显示开头的代码

$pdf = new PDF('P','mm',array(215.9,330.2));
$pdf->SetMargins(3,9,8,12.2);
$pdf->SetAutoPageBreak(true, 40);
$pdf->AliasNbPages();
$pdf->AddPage();
$pdf->AddFont('Century Gothic','B','gothicb.php');
$pdf->AddFont('Century Gothic','','century_gothic.php');
$pdf->isFinished = false;
$pdf->SetFont('Century Gothic','',10);
$pdf->SetY(84);  

0 个答案:

没有答案