Skip to content

pdfmake Alternative for HTML Invoices and What a Second Layout Costs a Year

pdfmake builds PDFs from a JavaScript definition, so every invoice change is made twice, once on the page and once in the definition. About $2,200 a year, against about $1,788 in year one 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 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 plan

pdfmake is popular because it needs no server. You describe a document as a JavaScript object, call createPdf and the browser or Node returns a PDF. The reason teams start searching for a pdfmake alternative is rarely the first invoice. It is the tenth one, when the design team changes the web invoice and someone has to translate that change into a document definition by hand.

The short answer

Keep pdfmake for documents you define in data, such as simple receipts, tickets and reports built from rows. Move to an HTML to PDF approach when the PDF is a customer-facing invoice or statement that has to look like the page in your app. In the example below, a second pdfmake layout costs about $2,200 a year, against about $1,188 for rendering the existing HTML with an API plan.

How does pdfmake build a document?

A pdfmake document is a docDefinition: nested arrays and objects with keys such as content, table, columns, stack and styles. The pdfmake documentation describes the layout model. It is a declarative layout engine of its own, not a browser, so it never reads your HTML or your CSS.

const docDefinition = {
  content: [
    { text: 'Invoice 2041', style: 'h1' },
    { table: { widths: ['*', 60, 80], body: lineItemRows } },
  ],
  styles: { h1: { fontSize: 18, bold: true } },
};
pdfMake.createPdf(docDefinition).download('invoice-2041.pdf');

That is pleasant for a table of rows. It becomes work when the same invoice also exists as a page, because the page is HTML with CSS and the PDF is this object. Nothing connects them.

Where does a pdfmake invoice start to cost money?

Two layouts. Every change to the web invoice (a new tax line, a second currency, a rebranded header) has to be repeated in the document definition. Customers notice when the two differ.

Fonts. pdfmake embeds only fonts you supply, bundled in a virtual file system. The default Roboto set is bundled, and every other face, including your brand font and any script it does not cover, has to be added as a file and registered. In the browser that also grows the JavaScript bundle by the size of the font files.

Page breaks and headers. Table headers can repeat through headerRows, and page breaks follow pdfmake rules. Fine control, such as keeping a totals block with its last line items, takes trial and error that a CSS break-inside: avoid would handle in one line. The page break guide lists the rules a browser applies.

No CSS reuse. Your design system, Tailwind classes and web components do not apply. Anything the page draws with JavaScript, such as a chart, has to be exported as an image and placed manually.

How much does a second pdfmake layout cost a year?

These are planning assumptions, not measurements, so replace them with your own. A team has an invoice page and a pdfmake definition. Each change needs about 2 hours on the page and 4 hours on the definition. Assume 5 changes a year, plus a one-off font and page break pass of 8 hours when the brand font is added.

ItemBasisYear one cost
pdfmake definition changes5 changes at 4 hours, $100 an hour$2,000
Font and page break work2 hours at $100$200
pdfmake second layout total$2,200
One-off move to rendering the web viewabout 6 hours at $100$600
SitePDF Growth, 50,000 renders a month$99 a month, billed monthly$1,188
HTML plus API total$1,788

Read the table honestly. In year one the API route costs about $1,788 against $2,200, a modest saving. In year two the one-off $600 is gone, so it is $1,188 against $2,000 or more. Yearly billing lowers the plan price further, see the pricing page. If your volume is 3,000 invoices a month rather than 50,000, check which plan fits first. And if the invoice almost never changes, the saving shrinks and staying put is reasonable.

What does a browser do that pdfmake does not?

A browser prints the page you already built. Flexbox and grid, web fonts, SVG logos and charts drawn by JavaScript come through unchanged, and a print stylesheet sets page size and margins. Text stays selectable and fonts embed as subsets, so the customer's accounting tool can read the numbers.

You also get something pdfmake cannot offer on its own: a record. With archive=true each render is stored with its date, so when a customer disputes a statement months later you can retrieve exactly what was issued. The invoice PDF API guide covers that flow.

Is the API the only way off pdfmake?

No. You can print the HTML in your own headless Chromium, and the Playwright cost breakdown shows what running that pool takes. If your stack is PHP, the mPDF alternative page covers the same decision. For a React front end, the React PDF renderer alternative page covers the equivalent trade.

When pdfmake is still the right choice

pdfmake suits documents that exist only as PDFs and are built from data: a ticket, a pick list, a one-page summary. It also suits an app that must produce a PDF entirely in the browser with no network call, and one whose volume makes any per-render fee unattractive. In those cases the second layout cost does not exist, because there is no first layout.

What to do this week

Take one real invoice, open the web view, and send its HTML to SitePDF. Compare the result with your pdfmake output line by line. The call takes the HTML you already have, returns a PDF link and, with archive=true, keeps a dated copy. If the two match and you stop maintaining the definition, you have your answer. The HTML to PDF in Node.js page shows the call in code.

Frequently asked questions

Does pdfmake support HTML and CSS?

No. pdfmake takes a JavaScript document definition, not HTML. A separate package can convert simple HTML into a definition, but it covers only a small set of tags and none of your stylesheet, so a styled web invoice still has to be rebuilt.

Is pdfmake good for invoices?

It can produce them, and for a fixed layout it works well. The cost appears when the invoice also exists as a web page, because the pdfmake definition has to be kept in step by hand every time the design or tax lines change.

What is a good alternative to pdfmake?

For documents that must match your web pages, rendering the HTML in headless Chromium is the closest alternative, either self-hosted or through an API. For data-driven documents with no web twin, another code-first library may be enough.

Can pdfmake use custom fonts?

Yes, but you must supply the font files and register them, and in the browser they are bundled into the JavaScript. Fonts that are not supplied are not embedded, so characters outside the bundled set can show as blanks.

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.

Get started

Render and archive with one API call

A pixel perfect PDF and a dated copy of the page from the same request. Plans from $49 a month, half price billed yearly.

HTML to PDF, in your browser

Buy the plan