Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7128375
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T11:07:55+00:00 2026-05-28T11:07:55+00:00

I am using TCPDF’s writeHtml function for a page that renders properly in the

  • 0

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’t seem to have an effect. Does anyone have experience with this?

I’d like to add here that the HTML is not always in my control, so I would prefer to do this with TCPDF options(and not by modifying the source html)

UPDATE: I am able to change the font size by setting it on the body. The only remaining problem is that, to render correctly in the browser, it needs to be 12px. To render correctly in the PDF, it needs be something like 30px. Do I set the media on the css? What is the media type for TCPDF?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T11:07:56+00:00Added an answer on May 28, 2026 at 11:07 am

    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 <style> tag outside the actualy HTML body.

    <?php
    
    $html = <<<EOF
    <!-- EXAMPLE OF CSS STYLE -->
    <style>
      h1 {
        color: navy;
        font-family: times;
        font-size: 24pt;
        text-decoration: underline;
      }
      p {
        color: red;
        font-family: helvetica;
        font-size: 12pt;
      }
    </style>
    <body>
    <h1>Example of <i>HTML + CSS</i></h1>
    <p>Example of 12pt styled paragraph.</p>
    </body>
    EOF;
    
    $pdf->writeHTML($html, true, false, true, false, '');
    
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm generating a PDF using TCPDF and lots of writeHTML() calls. Sometimes when I
I'm creating PDF files with PHP using TCPDF. I have a small problem with
I am using TCPDF to generate the PDF in one of my projects. I
I just started using TCPDF (output with HTML), and I do not understand why
I am using TCPDF with FPDI's bridge. The issue I'm having is that as
I'm trying to dynamically create a PDF using the TCPDF library in a document
Now my web app using class tcpdf to convert all pdf file (in English)
I am implementing node to PDF using Drupal and tcpdf. In such case I
I am using TCPDF for generating PDF documents and i want to convert a
Is it possible to output a pdf on the fly using: Response.ContentType=Application/pdf I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.