3
Is there any way to use bootstrap to style an html page that will later become a pdf? I’m using the mpdf60 plugin in php, and I only need the style boostrap offers to use it in exporting a pdf file.
Consider the following code:
<div class="row"><div class="col-lg-4"></div><div class="col-lg-4">
<h3>Teste PDF</h3></div><div class="col-lg-4"></div></div>
When I use it inside the $mpdf->Writehtml() function, the bootstrap style does not take, coming only html, or any inline css. Using this mpdf60 plugin or any other, there is some way I can use bootstrap as css?
Can you tell if bootstrap files are being loaded from within the method
$mpdf->WriteHTML()
? When it’s called the method$mpdf->Output()
a new page is generated, bootstrap relationships will not be inherited. Test...– Thyago ThySofT
No, only the page that is generating the pdf is who has the link to the bootstrap files...
– Diego Souza
Within the method
$mpdf->WriteHTML()
I use the call from css to pdf via<style>
define all the css there, because absolutely nothing is inherited, worth trying to call from within the method in<head>
the relationship links with the bootstrap.– Thyago ThySofT
I get it, if I then put the css content of bootstrap in there (it would be huge, I know), it would work?
– Diego Souza
Probably, but the PHP/PDF libraries as far as I have tested do not support all CSS. At the time of conversion it "kills" some tags and parameters, test there for us to know! =)
– Thyago ThySofT
It is worth considering other options outside the
mpdf
, like thephantomjs
andjsPDF
, see that response from Transform HTML to PDF, the proposed solution generates a PDF very faithful to the rendered on the page– Pedro Sanção