sashavalentina Posted May 12, 2021 Share Posted May 12, 2021 I wanted to do auto numbering for my tables with css using TCPDF. I tried both ways but it does not work at all. I tried the one in the documentation of tcpdf and it does not work too. Can anyone give me a piece of advice on how to make this work? These are the both ways i mentioned and it did not work. $htmlcontent .=' <style> table { counter-reset: rowNumber; } table tr::before { display: table-cell; counter-increment: rowNumber; content: counter(rowNumber) "."; padding-right: 0.3em; text-align: right; } </style> <table id="receiptTable" cellpadding="3" style="max-height: 1000px;"> <tr> <td width = "7%"style=" font-weight: normal;font-size: 12px;line-height: 17px;color: #000000;"> </td> <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> '; } for this i use the method of including external css into my tables but it does not work as well. I did make sure my file path is correct. (the code below) $htmlcontent .=' <style>.file_get_contents(css/receipt.css).</style> <table id="receiptTable" cellpadding="3" style="max-height: 1000px;"> <tr> <td width = "7%"style=" font-weight: normal;font-size: 12px;line-height: 17px;color: #000000;"> </td> <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> '; } Quote Link to comment https://forums.phpfreaks.com/topic/312677-how-do-i-add-css-in-tcpdf/ Share on other sites More sharing options...
requinix Posted May 12, 2021 Share Posted May 12, 2021 10 hours ago, sashavalentina said: I wanted to do auto numbering for my tables with css using TCPDF. I tried both ways but it does not work at all. What "both ways"? 10 hours ago, sashavalentina said: I tried the one in the documentation of tcpdf and it does not work too. Which one? I'm sure it can work, so there's probably something different about your code. Did you check that the HTML works in a regular webpage? What's the rest of the code? Quote Link to comment https://forums.phpfreaks.com/topic/312677-how-do-i-add-css-in-tcpdf/#findComment-1586510 Share on other sites More sharing options...
sashavalentina Posted May 16, 2021 Author Share Posted May 16, 2021 On 5/13/2021 at 2:18 AM, requinix said: What "both ways"? The codes that i have attached in this post Quote Link to comment https://forums.phpfreaks.com/topic/312677-how-do-i-add-css-in-tcpdf/#findComment-1586574 Share on other sites More sharing options...
Barand Posted May 16, 2021 Share Posted May 16, 2021 It would appear that some CSS is implemented (such as font-size, line-spacing, color and other basics) but others are not. Your counter appears to be in those that are not. Those that do work can be in a <style> section or in-line. There may be a list in the documentation, who knows? If there were a prize for the worst documentation, tcpdf would win it outright. I have to resort to examining the source code to find out what arguments each method requires and what it does. For the counter you may have to resort to the age-old method of outputting an incremented counter variable. Quote Link to comment https://forums.phpfreaks.com/topic/312677-how-do-i-add-css-in-tcpdf/#findComment-1586576 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.