0

On the first page(page1.php) which is an HTML form,content such as this is present:

<input type ="text" size="25"   name="first_name" />

Form action is set as this: <form action="printpdf.php" method="post" id="print">

I would like to create a pdf file using FPDF to take whatever is entered in the 'first_name' text field and be able to output in a PDF preferably by using $POST command in PHP. Any ideas on how I can do this using FPDF?

Many thanks for your help.

Igor Novoselov
  • 71
  • 3
  • 5
  • 10

2 Answers2

1

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

Note that this is taken almost directly from the FPDF tutorial.

If you're doing a lot with PDFs, you may consider using DOMPDF.

Mark Eirich
  • 10,016
  • 2
  • 25
  • 27
0

You can find some good example on: 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();
?>
KoolKabin
  • 17,157
  • 35
  • 107
  • 145