首页 > 解决方案 > 使用 PHP 从 HTML 文件生成 PDF 文件

问题描述

我正在尝试使用 PHP 从 HTML 页面生成 PDF。我正在使用 fpdf 库将 HTML 转换为 pdf。但是代码不能正常工作。谁能帮我找出我的代码的错误?

<?php

require('fpdf.php');

if (isset($_POST['signup'])) {

    $pdf=new FPDF();
    $pdf->AddPage();
    $fp = fopen("index.html","r");
    $strContent = fread($fp, filesize("index.html"));
    fclose($fp);
    $pdf->WriteHTML($strContent);
    $pdf->Output();
}
?>

这是我正在尝试的 PHP 代码。

标签: phphtmlfpdf

解决方案


推荐阅读