我试图在php表单提交期间生成动态pdf,并使用fpdf生成表单内容。有效。但现在我不知道如何安排这些元素。结果pdf格式为:
Results
_____________________________________________________________________________________
_____________________________________________________________________________________
Name: xyz Age/Sex: 28/F ; Date: 22/09/2014
Report No:36 Email: xyz@gmail.com
Mob: 9999999999
______________________________________________________________________________________
Class: Some Text from form
______________________________________________________________________________________
Interpretation: Some Text from form
______________________________________________________________________________________
Comments: Some Text from form
Name: xyz
Signature:
我尝试了这么多:
$pdf=new PDF_HTML();
$pdf->AliasNbPages();
$pdf->SetAutoPageBreak(true, 15);
$pdf->AddPage();
$pdf->SetFont('Arial','B',14);
$pdf->Cell( 0, 15, 'Results', 0, 0, 'C' );
$pdf->Ln(5);
$pdf->Line(10, 20, 210-10, 20);
$pdf->Line(10, 20, 210-10, 20);
$pdf->SetFont('Arial','B',7);
$pdf->Cell( 0, 29, 'Name :', 0, 0, 'L',0);
$pdf->write(2,$_POST['name']);
$pdf->Cell( 0, 29, 'Email :', 0, 0, 'R',0);
$pdf->write(2,$_POST['email']);
$pdf->Output();
但这并不奏效。任何人都可以帮我如何使用它。这是我第一次使用fpdf,而且我在谷歌搜索了很多,但没有找到解决方案。
答案 0 :(得分:0)
试试这个...
php.net/manual/en/pdf.examples-basic.php
<?php
$p = PDF_new();
/* open new PDF file; insert a file name to create the PDF on disk */
if (PDF_begin_document($p, "", "") == 0) {
die("Error: " . PDF_get_errmsg($p));
}
PDF_set_info($p, "Creator", "hello.php");
PDF_set_info($p, "Author", "Rainer Schaaf");
PDF_set_info($p, "Title", "Hello world (PHP)!");
PDF_begin_page_ext($p, 595, 842, "");
$font = PDF_load_font($p, "Helvetica-Bold", "winansi", "");
PDF_setfont($p, $font, 24.0);
PDF_set_text_pos($p, 50, 700);
PDF_show($p, "Hello world!");
PDF_continue_text($p, "(says PHP)");
PDF_end_page_ext($p, "");
PDF_end_document($p, "");
$buf = PDF_get_buffer($p);
$len = strlen($buf);
header("Content-type: application/pdf");
header("Content-Length: $len");
header("Content-Disposition: inline; filename=hello.pdf");
print $buf;
PDF_delete($p);
?>