我有一个查询。我想知道如何使用php动态地将数据插入到pdf中。 我不希望它从数据库中重新获得。但是用户可以在pdf上的那个文本字段上写一些内容。
想得到帮助的人谢谢
答案 0 :(得分:4)
您可以使用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/
插入页面是自我解释。