mPDF : text align with p , h1 - h6 in table not work

GoldenFingers picture GoldenFingers · Aug 23, 2015 · Viewed 11k times · Source

this code not work in table with mPDF php class enter image description here

    <table>
    <tr>
      <td class="contentDetails">
  <td class="contentDetails">
         <h3 style="text-align: right;"><strong>text align right</strong></h3>
         <h3 style="text-align: center;"><strong>text align center</strong></h3>
         <h3 style="text-align: left;"><strong>text align left</strong></h3>
     </td>
    </tr>
    </table>

i triad use

.contentDetails > h3 {display: block;} 

but not work and between td it's html from Editor tinymce

this full code from script and when do output found content the td text align left not right or center

<?php

$html = '
<h1>mPDF</h1>
    <table style="border-collapse: collapse;
    font-size: 12px;
    font-weight: 700;
    margin-top: 5px; 
    border-top: 1px solid #777;
    width: 100%;">
<tbody>
<tr>
  <td class="contentDetails">
         <h3 style="text-align: right;"><strong>text align right</strong></h3>
         <h3 style="text-align: center;"><strong>text align center</strong></h3>
         <h3 style="text-align: left;"><strong>text align left</strong></h3>
     </td>
</tr>
</tbody>
</table>';

include("mpdf.php");

$mpdf=new mPDF('c'); 
$mpdf->WriteHTML($html);

$mpdf->Output();

exit;
?>

Answer

Subin Thomas picture Subin Thomas · Aug 23, 2015

Try the below code. I think it will help you.

<table width="100%">
  <tr>
    <td class="contentDetails">
     <th align="left"> <h3><strong>text align right</strong></h3></th>
     <th align="center"> <h3><strong>text align center</strong></h3></th>
     <th align="right"> <h3><strong>text align left</strong></h3></th>
    </td>
  </tr>
</table>

using extra tags in this.