Guides

Fonts missing or wrong in HTML to PDF? 5 causes

Your page uses your brand font in the browser, but the PDF comes out in Times or a plain sans-serif. Or Chinese, Japanese or Korean text is simply missing. Chrome doesn't warn you when a font fails: it quietly uses a fallback. We tested each cause below with Chrome 155 and Puppeteer 25, and checked which fonts were actually embedded in the PDF with pdffonts.

SetupFont in the PDF
Web font from another origin, with CORS headerThe web font
Same font, server sends no Access-Control-Allow-OriginFallback (even with networkidle0)
Relative url(fonts/brand.ttf) passed to setContentFallback
Same, with a <base href> tag or a data URIThe web font
Slow font (2.5 s), Puppeteer defaultsThe web font
Slow font, waitForFonts: falseFallback
CJK text, no CJK font installedNothing: the text is blank

1. The font server doesn't send CORS headers

Browsers load fonts from another origin in CORS mode. If the font's server doesn't send Access-Control-Allow-Origin, Chrome throws the font away and uses the fallback. HTML passed with page.setContent() runs on about:blank, so every font URL counts as another origin. In our test the font was downloaded, but the PDF still used the fallback, with every waitUntil option.

Fix it on the server that hosts the font:

# nginx
location ~* \.(woff2?|ttf|otf)$ {
  add_header Access-Control-Allow-Origin *;
}

Google Fonts and most font CDNs already send this header. If you can't change the server, inline the font as a data URI (see below).

2. Relative font URLs with setContent

HTML passed as a string has no base URL, so src: url(fonts/brand.ttf) can't resolve and the font never loads. Either use absolute URLs, add a base tag, or embed the font:

<!-- Option A: a base URL for every relative link -->
<base href="https://your-site.example/">

<!-- Option B: embed the font, no network needed -->
<style>
@font-face {
  font-family: Brand;
  src: url(data:font/woff2;base64,d09GMgABAAAAA...) format('woff2');
}
</style>

A data URI also avoids the CORS problem above. Embed only the weights you use: each one adds its file size to every render.

3. The PDF is made before the font arrives

Puppeteer's page.pdf() waits for web fonts by default (the waitForFonts option, which defaults to true). In our test a font that took 2.5 seconds to download still made it into the PDF, even with waitUntil: 'domcontentloaded'. With waitForFonts: false it didn't. If you use another tool, or an old Puppeteer, wait for fonts yourself before printing:

await page.setContent(html, { waitUntil: 'domcontentloaded' });
await page.evaluate(() => document.fonts.ready);
await page.pdf({ path: 'out.pdf', format: 'A4' });

document.fonts.ready fixed the slow-font case for us even with waitForFonts: false. PDFLoom uses Puppeteer's default, so it waits for fonts that are loading. It can't fix a font that fails to load, though: check causes 1 and 2.

4. The font isn't installed on the server

A font name that works on your Mac often doesn't exist on a Linux server. Here is what our Ubuntu server, with DejaVu, Liberation and Noto fonts installed, actually embedded:

CSS font-familyFont in the PDF
Arial, HelveticaLiberation Sans
"Times New Roman"Liberation Serif
system-uiNoto Sans
"Segoe UI", Inter, -apple-system (no fallback)Liberation Serif

Arial and Helvetica map to Liberation Sans, which has the same letter widths, so line breaks stay the same. But a name the server doesn't know, with no fallback, ends in the default serif font. That's why PDFs so often come out in a Times-like font. Always end the stack with a generic family, and load the fonts you really need as web fonts:

body { font-family: Inter, "Segoe UI", Arial, sans-serif; }

5. Chinese, Japanese, Korean (or emoji) text is missing

If no installed font has the characters, Chrome can't draw them. In our test, with no CJK font on the server, Chinese, Japanese and Korean text came out completely blank: no boxes, just empty space. The text was still in the PDF's text layer, so copying it worked, which makes the problem easy to miss in automated checks. After installing Noto CJK, all three rendered correctly.

Slim Docker images often ship with no fonts at all. The node:22-bookworm-slim image has no /usr/share/fonts directory. Install fonts in your Dockerfile:

RUN apt-get update && apt-get install -y --no-install-recommends \
    fonts-liberation fonts-noto-cjk fonts-noto-color-emoji \
 && rm -rf /var/lib/apt/lists/*

Set the page language too. Without lang, Chrome drew Chinese text with the Japanese variant of Noto Sans CJK. With <html lang="zh-CN"> it used the Simplified Chinese one, and lang="ko" picked the Korean one. The shapes of some characters differ between the regional variants.

Restart your renderer after installing fonts. A browser that is already running may not see them.

How to check which fonts a PDF uses

pdffonts out.pdf
# name                    type          encoding    emb sub uni
# AAAAAA+LiberationSans   CID TrueType  Identity-H  yes yes yes
#   ^ a fallback, not your font

pdffonts is part of poppler-utils. If you see Liberation, DejaVu or Times instead of your font, go through the causes above. To see whether a font is installed on a Linux server, run fc-list | grep -i "segoe". Don't rely on fc-match for this: it suggested Noto Sans for "Segoe UI", but Chrome used its default serif font.

Related: background colors missing in HTML to PDF and CSS page breaks. PDFLoom's servers have Liberation, DejaVu, Noto (including CJK) and Noto Color Emoji installed. To check your own HTML, paste it into the free HTML to PDF converter.

Tested 26 November 2026 with Chrome 155 and Puppeteer 25.14: fonts served from a local server with and without CORS and with a 2.5 s delay, PDFs checked with pdffonts, and CJK output rasterised with pdftoppm to count drawn pixels.


More guides