vendredi 9 octobre 2020

html to pdf checkbox is not ticked when clicked

Hie folks! I'm generating pdf from HTML checkbox input using an mpdf library using useActiveForms property. The problem is that checkbox is never ticked when clicked the outline appears but that's all. By the way, all other inputs work ok - text inputs, radio buttons, selects - but I need this very checkbox! The problem is observed in browser google chrome and pdf-xchange viewer but all works fine in updated adobe acrobat reader dc and foxit reader. I was googling all the net through and I see that either I alone have such a problem or I don't know what to think! If anybody offers any decision for a browser will be very much obliged? My code is the following:

<?php
    require_once 'mpdf/vendor/autoload.php';
        
    ob_start();
    ?>
    <!doctype html>
    <html lang="en">
        <head>
            <title>Your form</title>
        </head>
        <body>
        <form>
            <input type="checkbox" name="check" checked="checked" value="rrrrr"> check me <br />
            <input type="text" name="text" value="" />
        </form>
        </body>
    </html>
    <?php
    $form = ob_get_contents();
    ob_end_clean();
    
    $mpdf = new \Mpdf\Mpdf([
        'margin_left' => 5,
        'margin_right' => 5,
        'margin_top' => 5,
        'margin_bottom' => 5,
        'margin_header' => 0,
        'margin_footer' => 0
    ]);
    $mpdf->useActiveForms = true;
    $mpdf->SetTitle("Checkbox test");
    $mpdf->SetAuthor("John Doe");
    $mpdf->SetDisplayMode(100);
    $mpdf->WriteHTML($form);// this generates the pdf
    $tmpfile = tempnam(sys_get_temp_dir(), 'pdf_');
    $mpdf->Output($tmpfile, 'F');
    header('Content-Type: application/octet-stream');
    header('Content-Disposition: attachment; filename="checks.pdf"');
    readfile($tmpfile);
?>

Thanks in advance!




Aucun commentaire:

Enregistrer un commentaire