Forum


Replies: 1   Views: 2842
Can't set font size to html
Topic closed:
Please note this is an old forum thread. Information in this post may be out-to-date and/or erroneous.
Every phpdocx version includes new features and improvements. Previously unsupported features may have been added to newer releases, or past issues may have been corrected.
We encourage you to download the current phpdocx version and check the Documentation available.

Posted by gh_ost  · 20-10-2017 - 10:13

Hi! PhpDocx premium version can't set font size to HTML. How can i solve this problem? 

$html = '<style>
            table {border: 0;border-collapse: collapse; font-size: 14px !important;}
            td {border: 1px solid black;font-size: 14px !important;}
        </style>';
$html .= '<table style="font-size: 14px"><tbody>';
$html .= '<tr><td>'.trans('persons.degree_exist').'</td><td>'.$degreeHas.'</td></tr>';
$html .= '</tbody></table>';
$word->embedHTML($html);

Posted by admin  · 20-10-2017 - 10:33

Hello,

We have tested it and it's working fine:

$html = '
<style>
  table {border: 0;border-collapse: collapse; font-size: 14px !important;}
  td {border: 1px solid black;font-size: 14px !important;}
</style>
<table style="font-size: 14px">
<tbody>
<tr>
  <td>
    This is a text
  </td>
  <td>
    Text B
  </td>
</tr>
<tr>
  <td>
    Text C
  </td>
  <td>
    Text D
  </td>
</tr>
</tbody>
</table>
';
$docx->embedHTML($html);

If we change the font size to 18, the font size is higher when we open the DOCX:

$docx = new CreateDocx();
$html = '
<style>
  table {border: 0;border-collapse: collapse; font-size: 18px !important;}
  td {border: 1px solid black;font-size: 18px !important;}
</style>
<table style="font-size: 18px">
<tbody>
<tr>
  <td>
    This is a text
  </td>
  <td>
    Text B
  </td>
</tr>
<tr>
  <td>
    Text C
  </td>
  <td>
    Text D
  </td>
</tr>
</tbody>
</table>
';
$docx->embedHTML($html);

We recommend you to check if Tidy for PHP is installed and enabled, test the previous scripts and check your script.

Regards.