[英]Outputting text fields into PDF file using FPDF
在HTML格式的第一页(page1.php)上,存在如下内容:
<input type ="text" size="25" name="first_name" />
表单操作设置如下: <form action="printpdf.php" method="post" id="print">
我想使用FPDF创建一个pdf文件,以接受在“ first_name
”文本字段中输入的所有内容,并且最好通过使用PHP中的$POST
命令以PDF格式输出。 关于如何使用FPDF做到这一点的任何想法?
非常感谢您的帮助。
index.html:
<form action="printpdf.php" method="post" id="print">
<input type="text" size="25" name="first_name" />
<input type="submit" />
</form>
printpdf.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教程 。
如果您要处理大量PDF,则可以考虑使用DOMPDF 。
您可以在以下位置找到一些很好的示例: 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();
?>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.