fpdf多单元不显示值

时间:2017-01-30 07:02:55

标签: php fpdf

我正在创建一个正在运行的pdf,但这些值没有输入pdf的多单元格。

让我们以日期为例,用户输入日期,在PDF上看起来应该是:

Date: 26/01/2017

但这就是现在的样子:

Date:

下面是我的代码,其中包含日期示例:

<?php
//set the question values
$questions     = array(
'name' => "Name: ",
'date' => "Date: ",
'first' => "First Day of Leave: ",
'last' => "Last Day of Leave: ",
'days' => "Number of Days Taken: ",
'email' => "Managers Email: ",
'creditdays' => "Leave Days in Credit",
'personnel' => "THIS SECTION TO BE COMPLETED BY PERSONNEL DEPARTMENT",
'credit' => "Leave Days in Credit:",
'mansign' => "Signed:",
'date2' => "Date:",
'authorise' => "Authorised By:",
'date3' => "Date:",
'auth' => "Authorisation Of Leave"
);
//set the question answers
$date          = $_POST['date'];
$first         = $_POST['first'];
$last          = $_POST['last'];
$days          = $_POST['days'];
$email         = $_POST['email'];
$name          = $_POST['name'];
//set the question names
$questionName  = $questions['name'];
$questionDate  = $questions['date'];
$questionFirst = $questions['first'];
$questionLast  = $questions['last'];
$questionDays  = $questions['days'];
$questionEmail = $questions['email'];
$personnel = $questions['personnel'];
$credit = $questions['credit'];
$mansign = $questions['mansign'];
$date2 = $questions['date2'];
$authorise = $questions['authorise'];
$date3 = $questions['date3'];
$auth = $questions['auth'];
//Create the PDF

require('fpdf.php');
$pdf = new FPDF();
$pdf->AddPage();

$pdf->SetFont('Arial', 'B', 16);
//insert fields
$pdf->SetDrawColor(100, 100, 100);
$pdf->SetFillColor(100,100,100);  
$pdf->Multicell(200, 3, "Leave Application Form", "", 'C');
$pdf->Ln();
$pdf->Ln();
$pdf->MultiCell(190, 10, $questionDate, $date, 'C');

1 个答案:

答案 0 :(得分:2)

根据fpdf manual

$pdf->MultiCell(190, 10, $questionDate, $date, 'C')

在您的代码中:

$date;

因此$pdf->MultiCell(190, 10, $questionDate . $date, 'C')不是 txt参数的一部分,而是出现在单元格中。 相反,您需要将$ date变量附加到$ questionDate。

(function() { var textFile = null, makeTextFile = function(text) { var data = new Blob([text], { type: 'text/plain' }); // If we are replacing a previously generated file we need to // manually revoke the object URL to avoid memory leaks. if (textFile !== null) { window.URL.revokeObjectURL(textFile); } textFile = window.URL.createObjectURL(data); return textFile; }; var create = document.getElementById('create'), textbox = document.getElementById('textbox'); create.addEventListener('click', function() { var link = document.getElementById('downloadlink'); link.href = makeTextFile(textbox.value); link.style.display = 'block'; }, false); })();;