使用php将数据插入pdf? [关闭]

I have a query. I would like to know how does one dynamically insert data to the pdf using php. I dont want it to be retrived from the database. But the user can just write something on that text field on the pdf.

Would like to get help guys thanks

You can use http://www.fpdf.org/:

from the examples:

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

$pdf = new FPDF();
$pdf->AddPage();
$pdf->SetFont('Arial','B',16);
$pdf->Cell(40,10,'Hello World!');
$pdf->Output();
?>

So taking directly from a form can be:

<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();
}
    ?>

If you already have an existent PDF

You can import it using this extension:

http://www.setasign.de/products/pdf-php-solutions/fpdi/

The pluging page is self explaining.