簡體   English   中英

使用FPDF將文本字段輸出到PDF文件

[英]Outputting text fields into PDF file using FPDF

在HTML格式的第一頁(page1.php)上,存在如下內容:

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

表單操作設置如下: <form action="printpdf.php" method="post" id="print">

我想使用FPDF創建一個pdf文件,以接受在“ first_name ”文本字段中輸入的所有內容,並且最好通過使用PHP中的$POST命令以PDF格式輸出。 關於如何使用FPDF做到這一點的任何想法?

非常感謝您的幫助。

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

請注意,這幾乎直接來自FPDF教程

如果您要處理大量PDF,則可以考慮使用DOMPDF

您可以在以下位置找到一些很好的示例: 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();
?>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM