mardi 3 mai 2016

Setting checkboxes and radiobuttons with FPDM in PDF form

I'm trying to fill out a PDF form through FPDM, like in this example: http://ift.tt/1xXFoff

Filling out text, date, decimal, ... inputs works correctly, but I can't find out how to check checkboxes and grouped checkboxes (radio buttons). This are two problems:

  1. Checkboxes have a regular name, like "mycheck1". Setting the value in the PHP array to true or or "true" or "1" or 1 or "checked" or "on" or "yes" doesn't activate the checkboxes (case-sensitively tested too). Which value do I have to set to activate checkboxes?
  2. Grouped checkboxes (radio buttons) cannot even be found - the script throws the error "FPDF-Merge Error: field yourtype not found". What is the correct name? Adobe Acrobat Pro DC shows the name "yourtype" as the name for all checkboxes in the group. In the field-list it shows the grouped checkboxes as "yourtype#0", "yourtype#1", "yourtype#2", etc. But the script doesn't seem to be able to find any of this names. I also tried something like "yourtype[1]" without luck. And as soon as I can access them, do I have to set the value for one of them, or do I assign the (integer?) value just directly?

My example:

<?php
    require('fpdm.php');

    $fields = array(
    'forname' => 'Jon Dow',  // text input: works
    'mycheck1' => true,  // checkbox: doesn't work! Also tried "true", 1, "1", "yes", "on", ... (with case-sensitive)
    'yourtype' => true,  // grouped checkbox (radio button): doesn't even find input with that name.
    );

    $pdf = new FPDM('template.pdf');
    $pdf->Load($fields, true);
    $pdf->Merge();
    $pdf->Output();
?>

Aucun commentaire:

Enregistrer un commentaire