Link to home
Start Free TrialLog in
Avatar of mosemadl
mosemadl

asked on

PHP and Form data to PDF

Anyone know how to select checkboxes in PDFs using PHP?

<?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)
    );

    $pdf = new FPDM('template.pdf');
    $pdf->Load($fields, true);
    $pdf->Merge();
    $pdf->Output();
?>
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

Checkboxes are a special-case thing in HTTP requests; if they are not checked, they are not part of the request.  Some special tricks may be needed to provide a default value.  I don't know what FPDM might be doing with the checkboxes, but it's certainly worth understanding how they work.
https://www.experts-exchange.com/articles/5450/Common-Sense-Examples-Using-Checkboxes-with-HTML-JavaScript-and-PHP.html
ASKER CERTIFIED SOLUTION
Avatar of Julian Hansen
Julian Hansen
Flag of South Africa image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mosemadl
mosemadl

ASKER

That helps. Unfortunately those notes are 5 years old :-(
Guess I'll have to get creative.
After a little more research, I found these comments in the most recent download.  Since this is dated 2011 and it says that the "to do" list includes checkboxes as a future objective, it's probably not been done.  Perhaps you can extend the class to add the form types, but I don't think it has the capability out of the box.
*@todo in the importance order, natively by fpdm                               *
*    -stream inline support (content change,repack,offset/size calculations)   *
*    -pdf inline protection                                                    *
*    -flatten support                                                          *
*    -extends filling to another form fields types (checkboxes,combos..)       *

Open in new window