如何在使用FPDF生成的PDF上编写_POST变量数据?

时间:2017-02-10 06:11:58

标签: php pdf fpdf

我正在使用PHP和外部库 NSCalendarMatchNextTime 和透明度脚本生成PDF: FPDF

代码:

HTML

<form name="myform" method="POST" target="_blank">
     <button type="submit" formaction="print.php"> Print </button>
     <input type ="text" name="name"></input>
</form>

PHP

<?php
require('alpha/alphapdf.php');
// Instanciation of inherited class
$pdf = new AlphaPDF();
$pdf->AddPage();
$pdf->SetLineWidth(1.5);
// draw jpeg image
$pdf->Image('my-image.jpg',0,0,220,300,'JPG');
// print name
$pdf->SetFont('Arial', '', 12);
$name = $_POST['$name'];
$pdf->Text(10,28,$name);
$pdf -> Output();
?>

1 个答案:

答案 0 :(得分:2)

$name = $_POST['$name'];

应该是

$name = $_POST['name'];

尝试var_dump($_POST)print_r($_POST)进行校对。 也尝试打印$_POST['$name']