I'm using CakePHP 1.3 to make an online application system. I try to print a PDF document using TCPDF based on a view.
I use the code
$this->writeHTML($this->render('print') )
in my print controller.
The problem is that I have this
undefined index : cols
error output to the screen. What could have gone wrong?
Apparently, TCPDF parses the <thead> element to determine the number of columns in a table when it outputs tables in PDF. Also, I would recommend to generally check if your HTML is valid if some other errors keep occurring.
Apparently, TCPDF parses the <thead> element to determine the number of columns in a table when it outputs tables in PDF. Also, I would recommend to generally check if your HTML is valid if some other errors keep occurring. I hope this helps.
This is because the tcpdf package does not allow wrong or incomplete html. I suggest that you should verify the code first. You may be missing something in your html? Show activity on this post.
and send that to TCPDF, everything comes out just fine. TCPDF requires valid XHTML code. You must clean up your HTML code before submitting it to TCPDF. I am. The code sent to TCPDF is:
TCPDF “Undefined index: cols” when using tables in view
In some cases you may forget the closing tag or define the wrong tag, resulting in this error. This is because the tcpdf package does not allow wrong or incomplete html. I suggest that you should verify the code first. You may be missing something in your html?
Otherwise swith to using simple html <table>
with <tr>
and <td>
I run into the same problem today (even though I am not using CakePHP), and all it took to fix this problem was to add a valid <thead>
element to every table that I was embedding. Apparently, TCPDF parses the <thead>
element to determine the number of columns in a table when it outputs tables in PDF.
Also, I would recommend to generally check if your HTML is valid if some other errors keep occurring.
I hope this helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With