Kingr008
Kingr008

Reputation: 11

HTML setting in order to convert it properly into a PDF

I would like to get a html brochure designed and then converted into pdf via html to PDF library.

I am trying to understand what size or how the html should be created in order for it to convert perfectly on a 8.5 x 11 PDF. So it can print out nicely on a single sheet of paper.

Upvotes: 1

Views: 262

Answers (1)

Weston
Weston

Reputation: 1857

First of all, you should be aware that the support for HTML in TCPDF is limited. If you want to create a fancy brochure with a precise and complex layout, it may be difficult.

I use TCPDF for database reports, and I use HTML tables for the page layout.

You can lock down the layout for 8.5x11 page size, by making a <table> for the page, and explicitly speciying the width of each cell:

    <table cellspacing="..whatever.." cellpadding="..whatever..">
      <tr>
        <td width="..whatever..">foo</td>
        <td width="..whatever..">bar</td>
      </tr>
    </table>

You'll still need to keep track of how many rows the page has room for. For database tabular style reports, this is fairly easy. For a more general "brochure" style report, it may be difficult.

You may be better of using something like wkhtmltopdf, which is a program written in C++, using qt and webkit to render HTML into PDF. (See http://code.google.com/p/wkhtmltopdf)

Upvotes: 1

Related Questions