How to make css works in tcpdf?

I want to implement the function of using css to number the rows of my table automatically in my tcpdf. I do not know why it does not work. I did check it in a regular website it works perfectly. But i do not know why when i added it into my tcpdf it does not work at all. Does anyone know the solution to this problem? Please help me. Any advice will be appreciated. Thanks in advance.

$htmlcontent .= '<style>
table {
    counter-reset: rowNumber;
  }
  
  table tr.receiptcontent::before {
    display: table-cell;
    counter-increment: rowNumber;
    content: counter(rowNumber) ".";
  
  }
   </style>';

$htmlcontent .='
<table cellpadding="11" style="max-height: 1000px;">
    <tr class="receiptcontent">

        <td colspan="3" style="font-weight: normal;font-size: 12px;line-height: 17px;color: #000000;">
            '.$irow['product_title'].'
        </td>
        
         <td style=" font-weight: normal;font-size: 12px;line-height: 17px;color: #000000;">
           '.$irow['product_sku'].'
        </td>
         <td style=" font-weight: normal;font-size: 12px;line-height: 17px;color: #000000;">
           '.$irow['quantity'].' '.$irow['quantity_unit'].'
        </td>
         <td style=" font-weight: normal;font-size: 12px;line-height: 17px;color: #000000;">
          RM '.$irow['product_buy_price'].'
        </td>
        <td  width= "20%" style=" font-weight: normal;font-size: 12px;line-height: 17px;color: #000000;">
            RM '.$irow['purchase_price'].'
        </td>
    </tr>
</table>

';
}

tcpdf is an old script. Don’t expect it to support CSS2 counters.

dompdf states it handles most CSS 2.1 properties, but like tcpdf, doesn’t appear to have any easily found documentation on what it does support. See if dompdf will work for you - GitHub - dompdf/dompdf: HTML to PDF converter for PHP

1 Like

you can also use mPDF lib. it also good

Sponsor our Newsletter | Privacy Policy | Terms of Service