TCPDF - Internal css not working
Hello Change Below line,
$htmlData .= "<table class='tableWithOuterBorder'><tr><td>Hello</td><td>Sir</td></tr></table>";
to
$htmlData .= '<table class="tableWithOuterBorder"><tr><td>Hello</td><td>Sir</td></tr></table>';
Just give class name in double quote("), and everything works properly.
My Final code is right now :
$htmlData = '<html><head>';
$htmlData .= '<style>
.tableWithOuterBorder{
border: 0.5px solid black;
border-collapse: separate;
border-spacing: 0;
}
</style>';
$htmlData .= '</head><body>';
$htmlData .= '<table class="tableWithOuterBorder"><tr><td>Hello</td><td>Sir</td></tr></table>';
$htmlData .= '</body></html>';
$pdf->writeHTML($htmlData, true, false, false, false, '');
Thanks
TCPDF not render all CSS properties
In the first place, you should note that PDF and HTML and different formats that hardly have anything in common. If TCPDF allows you to provide input data using HTML and CSS it's because it implements a simple parser for these two languages and tries to figure out how to translate that into PDF. So it's logical that TCPDF only supports a little subset of the HTML and CSS specification and, even in supported stuff, it's probably not as perfect as in first class web browsers.
Said that, the question is: what's supported and what's not? The documentation basically skips the issue and let's you enjoy the trial and error method.
Having a look at the source code, we can see there's a protected method called TCPDF::getHtmlDomArray()
that, among other things, parses CSS declarations. I can see stuff like font-family
, list-style-type
or text-indent
but there's no margin
or padding
as far as I can see and, definitively, there's no float
at all.
To sum up: with TCPDF, you can use CSS for some basic formatting. If you need to convert from HTML to PDF, it's the wrong tool. (If that's the case, may I suggest wkhtmltopdf?)
Bootstrap.min.css file is not calling in tcpdf
First of all - Bootstrap
use js
scripts for working; As You understand, scripts could not be working in tcpdf
file;
More than that - tcpdf
not allowed all CSS attributes; I can't find supported css list in official documentation, but this can help;
Related Topics
Strange Behaviour with Numbers That Have a Leading Zero
Query_Posts() Should Be Avoided
Laravel 4 - Logging SQL Queries
Does Utc Observe Daylight Saving Time
How to Pass an Array via $_Get in PHP
Getting a Checkbox Array Value from Post
Storing Arrays in the Database
How to Check the Performance of MySQL Indexing
How to Return Back Twice in Laravel
Concatenating a String and Primary Key Id While Inserting
How to Delete Object from Array Inside Foreach Loop
How to Get CPU Usage and Ram Usage Without Exec
How to Get Previous Month and Year Relative to Today, Using Strtotime and Date