【发布时间】:2013-08-10 05:48:02
【问题描述】:
我有一个问题。我想知道如何使用 php 将数据动态插入到 pdf 中。 我不希望从数据库中检索它。但是用户可以在 pdf 的那个文本字段上写一些东西。
希望得到帮助,谢谢
【问题讨论】:
-
我用php制作了一个pdf。我只想知道当pdf已经创建时用户如何输入数据..
标签: php html css sql pdf-generation
我有一个问题。我想知道如何使用 php 将数据动态插入到 pdf 中。 我不希望从数据库中检索它。但是用户可以在 pdf 的那个文本字段上写一些东西。
希望得到帮助,谢谢
【问题讨论】:
标签: php html css sql pdf-generation
你可以使用http://www.fpdf.org/:
来自示例:
<?php
require('fpdf.php');
$pdf = new FPDF();
$pdf->AddPage();
$pdf->SetFont('Arial','B',16);
$pdf->Cell(40,10,'Hello World!');
$pdf->Output();
?>
所以直接从表单中获取可以是:
<html><head></head>
<body>
<form method="POST" action="#">
<input type="text" name="content"><input type="submit" name="post">
</form>
</body>
</html>
<?php
require('fpdf.php');
if(isset($_POST['content'])){
$pdf = new FPDF();
$pdf->AddPage();
$pdf->SetFont('Arial','B',16);
$pdf->Cell(40,10,$_POST['content']);
$pdf->Output();
}
?>
如果您已有 PDF
你可以使用这个扩展来导入它:
http://www.setasign.de/products/pdf-php-solutions/fpdi/
插件页面是自我解释的。
【讨论】: