Home » Php » php – How to generate PDF from HTML with CSS bootstrap classes

php – How to generate PDF from HTML with CSS bootstrap classes

Posted by: admin July 12, 2020 Leave a comment

Questions:

I have a table with classes bootstrap3 css and I want to generate a PDF from this table…

What is the best way to do this?

I need that keep my style css
My table:

        <table id="tabelaVisitaSickbay" class="table table-striped table-hover table-bordered">
            <tbody>
            <tr>
                <th colspan="2">Visits to the SickBay</th>
            </tr>
            <tr>
                <td>Botafogo Pre-Nursery and Nursery</td>
                <td id="visitaBotaPrenurseryAndNursery" class="atendimentoVisitSickBay"></td>                   
            </tr>
        </tbody>

Thanks for help & pointers in advance.

How to&Answers:

You can try something like this:

http://codecanyon.net/item/awesome-conversion-script/6462891

or

http://www.sitepoint.com/convert-html-to-pdf-with-dompdf/

Answer:

You’re right most tools as mentioned on this site do not support Bootstrap (fully). There are two APIs out there, who’s sites are actually in Bootstrap as well. They’re built by the company I work for (disclaimer):

  • HTM2PDF – has a HTML to PDF API for all programming languages and an SDK in PHP
  • PDFmyURL – has a webpage to PDF API, an API for complete websites to PDF and libraries in PHP and .NET