php – FPDF – PDF Form multilines and formatting-ThrowExceptions

Exception or error:

I’m using FPDF to generate PDF. I use a PDF template created on Adobe Acrobat that include form inputs.

I’ve been using the following code to generate my pdf :

<?php

***************************
  Sample using a PHP array
****************************/

require('fpdm.php');

$fields = array(
    'date' => '07/07/2017',
    'names' => 'Something',

);

$pdf = new FPDM('Singlepage.pdf');
$pdf->Load($fields, true); // second parameter: false if field values are in ISO-8859-1, true if UTF-8
$pdf->Merge();
$pdf->Output();
?>

It’s working perfectly but now i’d like to add multiples lines to my "names" form. Something like 'names' => 'Someone1 \n Someone2But I can’t figure out how to do it.

On my pdf template, I added the “multiples lines” to the text input.

Do you have any idea ?

And then i’d like to format this text, so I could add bold, italic etc to the text

How to solve:

The problem are the single quotes, change to double quotes and it will work (if the field is multi-line, of course):

$fields = array(
    'date' => '07/07/2017',
    'names' => "Something \n more",
);

Leave a Reply

Your email address will not be published. Required fields are marked *