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.
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 .
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();
?>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.