The journal · 20 November 2026 · 6 min read
TCPDF Alternative for HTML Invoices and What a Second PDF Template Costs a Year
TCPDF parses its own subset of HTML, so invoices live in a second, table based template. Keeping it in step costs about $2,600 a year, against about $1,188 for rendering the web view with an API plan.
Live demo
Runs in your browser. Nothing is uploaded. One PDF free to try, then a plan.
Your HTML
Live preview
Your PDF is downloading. That was the free one. The Starter plan converts as many as you need, for $49 a month or $288 a year, half price.
See the planTCPDF has been generating PDFs from PHP for well over a decade, and a lot of invoice code in production still calls it. The usual trigger for looking at a TCPDF alternative is a request the library handles badly: make the PDF look like the web page, add a second language, or put a chart in the statement. This post sets out what TCPDF does well, where its HTML support stops, and what moving the template to a rendering API costs in a year.
The short answer
Keep TCPDF for documents you draw with coordinates, such as labels, certificates and fixed forms, and for work that needs its PDF specific features. Move to an HTML to PDF approach when the document is a table-heavy invoice or statement that should match the on-screen design. In the example below, keeping a TCPDF layout in step with a web template costs about $2,600 a year in engineering time, against $588 for a 50,000 render API plan.
What does TCPDF actually do with HTML?
TCPDF has a method, writeHTML(), that accepts a limited set of tags and inline CSS. It is documented on the TCPDF site together with the other drawing and form methods. The HTML support is its own parser, not a browser. It reads tables, basic text styling and images, and it does not implement flexbox, grid, CSS variables or most of what a current stylesheet uses. JavaScript is never executed.
$pdf = new TCPDF('P', 'mm', 'A4', true, 'UTF-8');
$pdf->AddPage();
$pdf->SetFont('dejavusans', '', 10);
$pdf->writeHTML($invoiceTableHtml, true, false, true, false, '');
// $invoiceTableHtml has to be table based, with inline styles
That is why TCPDF invoices tend to be built from nested tables with inline styles, kept in a separate template from the page the customer sees. The two drift apart, and every design change is made twice.
How much does a second template cost a year?
These are planning assumptions, not measurements, so replace them with your own. A team has the invoice as a web view and as a TCPDF template. Each design or tax change needs about 3 hours in the web view and 5 hours in the TCPDF version, because tables and inline styles must be rebuilt and checked page by page. There are 4 such changes a year, plus 12 hours a year for font and page break fixes. Engineering time is valued at $100 an hour.
| Item | Basis | Year one cost |
|---|---|---|
| TCPDF template changes | 4 changes at 5 hours, $100 an hour | $2,000 |
| Font and page break fixes | 6 hours at $100 | $600 |
| TCPDF second template total | $2,600 | |
| One-off move to rendering the web view | about 6 hours at $100 | $600 |
| SitePDF Growth, 50,000 renders a month | $99 list, about $49 a month on yearly billing | $588 |
| HTML plus API total | $1,188 |
The API route is cheaper in year one and the gap grows in year two, because only the $588 repeats. If your TCPDF invoice rarely changes, the saving shrinks and staying put is reasonable. The figure to challenge is the hours per change, so time your last one.
What can a browser render that TCPDF cannot?
A browser prints the page you already designed. Flexbox and grid layouts, web fonts, SVG logos and charts drawn by JavaScript all come through, and CSS such as thead { display: table-header-group } repeats the table header on every page. The page break rules are covered in HTML to PDF page breaks. If your TCPDF output has wrong fonts or missing glyphs, HTML to PDF fonts not loading explains the browser side of that problem.
Text stays real, selectable text, and fonts embed as subsets, so the customer's accounting tool can read the numbers.
Is moving to Chromium the only option?
No. Another PHP library can replace TCPDF without changing the architecture. The mPDF alternative and dompdf alternative pages describe the same ceiling in those two libraries, since all three use their own CSS engine. Running headless Chrome yourself is the second route, and its yearly cost is worked out in what Playwright costs in production. The third is a hosted renderer, which is what Laravel HTML to PDF shows in a queued job.
The same second-template problem shows up outside PHP. The pdfmake version of this cost breakdown runs the numbers for JavaScript teams.
When TCPDF is still the right choice
TCPDF suits documents with fixed positions: labels, barcodes, certificates, filled forms. It also offers PDF specific features such as digital signatures, which a browser print does not give you. It needs no outside service, so it works when data may not leave your server. For invoice-shaped documents the economics tip the other way, and the invoice PDF API post covers what matters there: archive copies, retries and numbering.
What to do this week
Render one real invoice from your web view through SitePDF and compare it with the TCPDF output. The call takes the HTML you already have, returns a PDF link and, with archive=true, stores a dated copy of what the customer received. See pricing for the plan that fits your volume.
If your team also builds on-chain or financial dashboards, a data source such as Bitcoindatabase can feed the same HTML report that you render to PDF.
Frequently asked questions
Does TCPDF support CSS?
Partly. TCPDF reads inline styles and a small set of CSS properties through writeHTML(), mostly for tables and text. It does not implement flexbox, grid or CSS variables, and it runs no JavaScript, so modern stylesheets need a table based rewrite.
Is TCPDF good for invoices?
It can produce them, usually from a table based template with inline styles. That works for a fixed layout and becomes costly when the design changes often, because the PDF template must be kept in step with the web invoice.
What is a good alternative to TCPDF?
For simple documents, mPDF or dompdf are close PHP alternatives. For layouts that must match the browser, a Chromium based renderer is the better fit, either self-hosted or called as an API.
Can TCPDF convert HTML with flexbox to PDF?
No. TCPDF has its own HTML parser and does not implement flexbox or grid. A flexbox layout has to be rebuilt with tables, or rendered by a real browser engine such as Chromium.
Written by the team behind SitePDF, an HTML to PDF API that archives every page it renders. The in-browser converter is free to try, and API plans start at $49 a month, half price billed yearly.