codeshell / fpdm

PDF form filling using FPDM Class written by FPDF author Olivier (+multifile-filling-fix, +checkboxes)
MIT License
117 stars 66 forks source link

Mapping fields in the template with the values in Array #65

Open sanjoyroy opened 2 years ago

sanjoyroy commented 2 years ago

I have a predefined template that was supplied by a client, it uses a lot of checkboxes and radio buttons and based on the records I need to set those fields true or false. How do we map the field names (like name, address, city, phone etc) used in template.pdf so that can substitute the values in the array? Does the PDFtk tool helps in doing that, when I installed it, it is command based, please shed some light?

require('fpdm.php');

$fields = array( 'name' => 'My name', 'address' => 'My address', 'city' => 'My city', 'phone' => 'My phone number' );

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