HTML Rendering with TCPDF(PHP)

后端 未结 3 1704
独厮守ぢ
独厮守ぢ 2020-12-18 12:15

I am using TCPDF\'s writeHtml function for a page that renders properly in the browser. In the output PDF, the fonts are too small. I\'ve tried with setFont, but it doesn\'

3条回答
  •  天命终不由人
    2020-12-18 12:30

    Are you using tags? tcpdf's HTML engine gives the tag precedence over any CSS, or other size-adjusting tags. If you remove any extraneous tags from the HTML and use straight CSS, things should render as expected. Or, if you aren't using CSS, you should. Just because a browser displays it correctly doesn't mean it will look the same on other formats. The browser has likely performed some magic of its own to fill in the gaps in your CSS specifications.


    UPDATE

    Here's an example of specifying CSS declarations with your HTML when using tcpdf. Note how all the styling is applied using the CSS declarations inside the

    Example of HTML + CSS

    Example of 12pt styled paragraph.

    EOF; $pdf->writeHTML($html, true, false, true, false, ''); ?>

提交回复
热议问题