【问题标题】:Insert data to the pdf using php? [closed]使用php将数据插入pdf? [关闭]
【发布时间】:2013-08-10 05:48:02
【问题描述】:

我有一个问题。我想知道如何使用 php 将数据动态插入到 pdf 中。 我不希望从数据库中检索它。但是用户可以在 pdf 的那个文本字段上写一些东西。

希望得到帮助,谢谢

【问题讨论】:

  • 我用php制作了一个pdf。我只想知道当pdf已经创建时用户如何输入数据..

标签: php html css sql pdf-generation


【解决方案1】:

你可以使用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/

插件页面是自我解释的。

【讨论】:

  • 非常感谢。我真的很感激。
  • @julia,如果我的回答“符合”您的问题,请记住将其标记为正确的! :)
猜你喜欢
  • 2013-01-04
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-09-25
  • 1970-01-01
相关资源
最近更新 更多