php - fpdf: header 在 fpdf 中不起作用

标签 php fpdf

我使用了 fpdf 库并根据 fpdf 的官方文档使用它。

我想在我的文件中使用标题但不能使用它,下面是我的代码。请纠正我的错误,为什么标题没有出现..

这是我的代码:

<?php

require('fpdf/fpdf.php');

class PDF extends FPDF
{
function Header()
{
    // Select Arial bold 15
    $this->SetFont('Arial','B',5);
    // Move to the right
    $this->Cell(80,'ddd');
    // Framed title
    $this->Cell(30,10,'Title',1,0,'C');
    $this->Cell(20,10,'Title',1,1,'C');
    // Line break
    $this->Ln(20);
}
}

$pdf=new FPDF();

$pdf->AddPage();
$pdf->SetFont('Times','B',14);

$pdf->Cell(20,10,'Title',1,1,'C');
$pdf->Output();
?>

最佳答案

根据 PetrHejda 的评论,您需要做的就是改变

$pdf=new FPDF();

$pdf=new PDF();

关于php - fpdf: header 在 fpdf 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36682212/

相关文章:

php - 将 $_GET 和 $_POST 分配给单个变量

php - 将值插入两个相关表中

php - 是否可以使用 Fpdf 生成 Pdf 设计

php - 如何在 Uploadify 中实现选择文件夹选项?

php - 使用一个变量在两个表中查找信息

javascript - AJAX 在页面加载之前运行 onchange 事件

php - FPDF - 放置前确定 MultiCell 的高度?

php - 如何在 php 中在现有 pdf 文件上写入

php - FPDF错误: Unsupported image type: image/jpeg

php - FPDF/PHP : Footer page is display at the bottom of the next page (Blank page)