现在的位置: 首页php-基础语法>正文
向fpdf中插入页眉和页脚  
发表于581 天前 php-基础语法 评论关闭

现在做fpdf文档时如何添加上网站的标识,但是不被别人厌恶呢?

理所当然的是通过向fpdf中插入页眉和页脚PHP的fpdf类库重写Header方法和Footer方法实现。

例如:

<?php
define('FPDF_FONTPATH','font/');
require_once('fpdf/fpdf.php');
class PDF extends FPDF
{
 function Header()
 {
  $this->SetFont('Arial','B','15');
  $this->Cell(80);
  $this->Cell(30,10,'welcome to www.phpdo.net');
  $this->Ln(20);
 }
 function Footer()
 {
  $this->SetY(-15); //叶面上的Y坐标,单位为毫米,负数表示从页面底部向上的距离
  $this->SetFont('Arial','B','15');
  $this->Cell(0,10,'Page -'.$this->PageNo()); //PageNo函数输出页码
 }
}
$pdf = new PDF('P','mm','A4');
$pdf->Open();
$pdf->AddPage();
$pdf->SetFont('Courier','I','20');
$pdf->Cell(10,10,'www.phpdo.net');
$pdf->Output('');
?>

报歉!评论已关闭.

不想听你唠叨×