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

13,326

Solution 1

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.

Solution 2

I have prepared a lot of hours a content to print (mPdf v.6). Now i can give an advice to all. Don't use tables to align content or simply hold the content. Almost all css properties of elements work fine. But - but must not be nested in table.

Share:
13,326
GoldenFingers
Author by

GoldenFingers

Updated on June 05, 2022

Comments

  • GoldenFingers
    GoldenFingers almost 2 years

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