Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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;
?>
like image 310
GoldenFingers Avatar asked Aug 23 '15 07:08

GoldenFingers


People also ask

How do I align text in a table header?

HTML | <thead> align Attribute left: It sets the text left-align. right: It sets the text right-align. center: It sets the text center-align. justify: It stretches the text to set the width of all lines equal in table head.

How do I center align text in a table?

To center align text in table cells, use the CSS property text-align. The <table> tag align attribute was used before, but HTML5 deprecated the attribute. Do not use it. So, use CSS to align text in table cells.

How do I align text in h1?

To set the heading alignment in HTML, use the style attribute. The style attribute specifies an inline style for an element. The attribute is used with the HTML <h1> to <h6> tag, with the CSS property text-align. HTML5 do not support the align attribute of the heading tag, so the CSS style is used to set alignment.


1 Answers

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.

like image 184
Subin Thomas Avatar answered Oct 21 '22 07:10

Subin Thomas