0

I am trying to generate pdf using fpdf library and php .

I want to pdf output like :

------------               -------------
 Grad Marks                90%
 Documnets attched         Mark Sheet, I.C. or TC, Caste
                           Certificate, Eligibility Form, Bonafide,
                           Passing Certificate
 Why do you want to        Because I want to build my career
 take  admission in        in management field.
 MBA?

So I have written a piece of code

$pdf = new FPDF();
$pdf->AddPage();
foreach ($userInputs as $key => $value) {
 $pdf->Ln(7);
            $pdf->SetFont('Helvetica', 'B', 10);
            $pdf->MultiCell(90.5, 2.7, $key, 0, 'L', false);
            $pdf->SetFont('Helvetica', '', 10);
            $pdf->MultiCell(60, 2.7, $value, 0, 'L', false);
        }
    }
$pdf->Output();

N:B - Where $userInput is an array contains (Grad Marks,Documnets attched, Why do u ...) as key and (90%,Marks sheet..., Because I want ...) as values.

But I am not getting the desired output. I am getting out put like

------------              
 Grad Marks                
 90%
 Documnets attched         
 Mark Sheet, I.C. or TC, Caste
 Certificate, Eligibility Form, Bonafide,
 Passing Certificate
 Why do you want to 
 take  admission in        
 MBA?
 Because I want to build my career
 in management field.

So please help me out to get the desired output.

Thanks in advance.

4

1 回答 1

0

请在http://www.fpdf.org/en/script/script41.phpwriteHTML()看一下使用函数的例子

然后尝试这样的事情

$pdf = new PDF_HTML();
$pdf->AddPage();
$html ='<table>';
foreach ($userInputs as $key => $value) {
   html.='<tr><td>$key</td><td>$value</td></tr>';  
}
$html .= '</table>';
$pdf->Output();
于 2016-06-09T08:38:16.617 回答