Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP mPDF check-boxes checked in PDF

Disclaimer: know nothing about mPDF :(

I'm creating a PDF file using mPDF, I've manage to get the table printed successfully. I'm having some issues when it comes to getting my checkboxs checked. The checkboxes does not get checked in PDF view, but if I view the same code in HTML it does get checked. for instance

$output .= '<td width="50%" colspan="2">';
  $output .= '<strong>Instructed Another Solicito?</strong> ';
  $output .= 'Yes <input type="checkbox" checked /> ';
  $output .= 'No &nbsp; <input type="checkbox" />';
$output .= '</td>';

If I view them in HTML echo $output; format yes is checked but as soon as I output a pdf file i.e. $mpdf->WriteHTML($html); $mpdf->Output(); show as unchecked.

What do I have to do in order to get my checkboxes checked is there any other way to get this

Any Idea?

like image 523
Sharif Avatar asked Aug 11 '14 11:08

Sharif


2 Answers

You should use checked="checked"

like image 87
Amjad Avatar answered Sep 21 '22 16:09

Amjad


For those that fell onto this wanting to print a tick symbol, or use the standard symbols at all, read this documentation.

Essentially there are standard fonts that aren't embedded in the document, as they are included in all PDF readers. This is used by default by mPDF, as it creates the smallest documents with the least processing time. These fonts don't include all but the essential symbols, so no tick symbol etc.

However, you can get mPDF to embed a "full" font quite easily, for instance to print a tick:

<p style='font-family:helvetica'>&#10004;</p>

Other standard fonts are available if you look in the docs :)

like image 36
Jamie Robinson Avatar answered Sep 21 '22 16:09

Jamie Robinson