Search code examples
phphtml-tableinlinetcpdf

TCPDF Side by Side Table


I'm using TCPDF to print some document record. But my second table will always next to the bottom of the first table (just like the image). I need to make the second is on the left side of the first table. Any code warrior please ... :)

enter image description here

Here's my code so far ...

enter image description here


Solution

  • If you want to have a table side-by-side, you have to create a parent table where the width is 100% and the one pair of "tr" and 2 pairs of "td" and, on each of "td" make another table. Here is the draft:

    <table width="100%" cellpadding="0" border="0">
        <tr>
            // Left side Table
            <td width="50%">
                <table width="100%" border="1">
                    <tr><td>Data goes here</td></tr>
                </table>    
            </td>
    
            // Right side Table
            <td width="50%">
                <table width="100%" border="1">
                    <tr><td>Data goes here</td></tr>
                </table>   
            </td>
        </tr>
    </table>
    

    It seems your using writeHTML per group, why not just use one and apply the parent table with two child table, you just have to use concat.