Skip to content
Getprintoza
Features How it works Pricing FAQ API docs
Log in Get API key

Custom web font missing in your Puppeteer or Playwright PDF? Check these 4 things in order

You added an @font-face rule or a Google Fonts link. The page looks right in a normal browser, but the PDF comes out in a default font. This is one of the most repeated complaints in the Puppeteer issue tracker, and it has several different causes. Work through them in this order.

1. Reachable? 2. Ready? 3. Server fonts 4. Name and weight Check the PDF One API call FAQ

1. Can the headless browser reach the font?

The browser that makes the PDF fetches the font itself. If the font URL is blocked, needs cookies, or fails a cross-origin (CORS) check, the browser quietly falls back to another font and nothing is reported.

Open DevTools in a normal browser, go to the Network tab, filter by “Font” and look for failed or blocked requests. If the font comes from another domain, that server must send an Access-Control-Allow-Origin header that allows your page.

One way to remove the network from the picture is to embed the font in the HTML as a base64 data: URL inside @font-face. There is no request and no CORS check. It is not a cure for everything: in the Puppeteer thread on this problem, several people used it, one said it still failed for them in headless mode, and another said it made their PDFs very large.

2. Is the font ready before the PDF is taken?

Fonts load asynchronously. A common suggestion is to wait for them before you call page.pdf():

await page.setContent(html, { waitUntil: 'networkidle0' });
await page.evaluate(() => document.fonts.ready);
const pdf = await page.pdf({ format: 'A4', printBackground: true });

The reports are mixed. In the old Puppeteer thread, one person said document.fonts.ready solved it and another said it did not change anything. One person said waitUntil: 'networkidle0' made web fonts appear, at the cost of roughly half a second per PDF, and another said changing waitUntil did not help. The wait is cheap, so it is worth keeping, but do not assume timing is your cause. Test on your own Puppeteer version.

3. Is the server missing fonts?

If the PDF looks right on your laptop and wrong on the server, the server is the difference. Minimal Linux images and AWS Lambda ship very few fonts. Families you list in font-family as fallbacks, such as Arial, Times New Roman or Calibri, may not exist there, and a missing font family is not an error. The look just changes.

What people report working:

  • Docker: install the font on the system. In the Puppeteer thread, one person fixed PDF rendering in Docker by installing the font as a system font, copying the .ttf into /usr/share/fonts/truetype/, and referencing it by name. After adding font files, refresh the font cache with fc-cache -f. That step is a standard fontconfig command, not something the thread mentions, and the exact folder and package names depend on your base image, so check them for yours.
  • AWS Lambda with @sparticuz/chromium: its README says Lambda has no fonts of its own and the package ships only Open Sans, which covers Latin, Greek and Cyrillic. You can add .ttf files in a folder named fonts or .fonts, zipped and uploaded as a Lambda layer, with the folder at the top of the zip.
  • Lambda container image: one commenter in that project's font issue installed fonts in a container image and only got them to load after setting FONTCONFIG_PATH to /etc/fonts before the library was loaded. That is one report from one setup, so treat it as something to try, not a rule.

For scripts such as Arabic, Chinese or Devanagari, and for emoji, the machine needs fonts that contain those characters, which is a different problem from a web font not applying. See the guide to empty boxes in Puppeteer PDFs and the emoji guide.

4. Is the font name or weight wrong?

The usual quiet mistakes:

  • The font-family name in your CSS does not match the name in @font-face.
  • You declared only a regular weight, but the page uses bold, so the browser fakes the bold.
  • The font file does not contain the characters you print. That shows up as empty boxes or another font for those characters, not as a wrong style everywhere.

A quick check from inside the page: list the fonts the page declared and their load status.

await page.evaluate(() =>
  [...document.fonts].map(f => f.family + ' ' + f.status)
);

A font with status error or unloaded tells you where to look.

Check what ended up in the PDF

Do not judge by eye only. On Linux and macOS, pdffonts output.pdf (from the poppler tools) lists the fonts that are really embedded. If your font is not in the list, the PDF never used it.

Skip the font setup: one API call

If you would rather not maintain fonts on your own server, Getprintoza is an HTML to PDF API that runs real Chromium with fonts for 12 languages already installed, including Arabic, Chinese, Hindi, Korean and Turkish. We don't store your HTML or PDFs. If the conversion cannot draw some characters, the response carries an X-Getprintoza-Warnings header that lists them. It is one option, and the four checks above work without it.

curl -X POST https://getprintoza.com/v1/convert \
  -H "x-api-key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"html": "<meta charset=\"utf-8\"><h1>Invoice</h1><p>Merhaba مرحبا 你好</p>"}' \
  --output invoice.pdf

The Free plan includes 50 PDFs a month and needs no card. Get a free API key, read the API documentation or see the pricing.

FAQ

Why does my custom font work in the browser but not in the PDF?
The PDF is made by a headless browser that loads the font on its own. If it cannot reach the file, or the font is not ready when the PDF is taken, it falls back to another font.

Does document.fonts.ready fix it?
Sometimes. Reports in the Puppeteer thread are mixed, so test it on your own version.

Why is it right on my laptop and wrong on the server?
Your laptop has fonts the server does not. Minimal Docker images and AWS Lambda ship very few.

How do I see which fonts the PDF really uses?
Run pdffonts on the file. A font missing from that list was never used.

Getprintoza

HTML to PDF for every language.

Product

Features Pricing FAQ API docs

Legal

Terms Privacy Policy Refunds

Help

support@getprintoza.com
© 2026 Getprintoza. All rights reserved.Twelve languages, right-to-left included.