【问题标题】:Outputting text fields into PDF file using FPDF使用 FPDF 将文本字段输出到 PDF 文件
【发布时间】:2011-07-18 14:07:32
【问题描述】:

在作为 HTML 表单的第一页(page1.php)上,存在如下内容:

<input type ="text" size="25"   name="first_name" />

表单动作设置为:&lt;form action="printpdf.php" method="post" id="print"&gt;

我想使用 FPDF 创建一个 pdf 文件,以获取在“first_name”文本字段中输入的任何内容,并能够最好通过在 PHP 中使用$POST 命令以 PDF 格式输出。 关于如何使用 FPDF 做到这一点的任何想法?

非常感谢您的帮助。

【问题讨论】:

标签: php fpdf


【解决方案1】:

index.html:

<form action="printpdf.php" method="post" id="print">
    <input type="text" size="25" name="first_name" />
    <input type="submit" />
</form>

打印pdf.php:

<?php
require('fpdf.php');

$pdf = new FPDF();
$pdf->AddPage();
$pdf->SetFont('Arial', 'B', 16);
$pdf->Cell(40, 10, $_POST['first_name']);
$pdf->Output();
?>

请注意,这几乎直接来自FPDF tutorial

如果您经常使用 PDF,可以考虑使用DOMPDF

【讨论】:

  • 感谢您的帮助。它解决了问题。我正在从头开始学习 FPDF 的工作方式。再次感谢。
【解决方案2】:

您可以在以下位置找到一些很好的示例: http://www.fpdf.org/

<?php
require('fpdf.php');

$pdf=new FPDF();
$pdf->AddPage();
$pdf->SetFont('Arial','B',16);
$pdf->Cell(40,10,$_POST['first_name']);
$pdf->Output();
?>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-04-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多