To render a webpage as a PDF with custom fonts in Docker, make the fonts available to Chromium—either install them in the container or load them through the page’s CSS—then wait for font loading before calling Puppeteer’s page.pdf(). Puppeteer waits for fonts by default during PDF generation. The example below installs local fonts in a Docker image, checks font loading in the page, and saves a PDF.
Choose how to provide the custom fonts
Use the delivery method that fits how the page and container are managed. These are implementation options, not a universal reliability or performance ranking.
As an Amazon Associate I earn from qualifying purchases.
| Approach | Use it when | What to check |
|---|---|---|
| Install fonts in the container | The page expects fonts installed on the host, several pages share the same fonts, or rendering must not depend on fetching font files at capture time. | Copy the files into a font directory supported by your Linux distribution, refresh its font cache where needed, and ensure the Chromium process can see the fonts. |
| Load fonts through page CSS | You control the page’s CSS or HTML and can declare the font with @font-face. |
Make sure the font URL is reachable from the browser container and that the font request completes before PDF generation. |
In either case, the CSS font-family must refer to the face you actually installed or declared, and that font file must contain the glyphs used by the document. A font can load successfully yet still lack particular characters, such as a symbol or a character from another writing system.
Build a Puppeteer image with local fonts
The Dockerfile below follows the local-font approach. It uses Puppeteer’s published Docker image and copies font files from a directory named fonts beside the Dockerfile. The example uses /usr/local/share/fonts/ and fc-cache -fv, a community implementation pattern; font directories, font-cache tools, and package names can vary by base distribution. Check these commands against the image you use.
#1 Best Overall
- PORTABLE SCANNER FOR USE ON-THE-GO — The fastest and lightest mobile single-sheet-fed compact document scanner in its class¹
- QUICK DOCUMENT SCANNING ― This Epson ultra-fast scanner scans a single page as quickly as 5.5 seconds²; Windows and Mac compatible
- VERSATILE PAPER HANDLING ― Portable scanner scans documents up to 8.5 x 72 in; Also easily digitizes receipts and ID cards to make accounting, bookkeeping, and organizing simpler
- INTUITIVE, HIGH-SPEED SOFTWARE — Epson ScanSmart Software³ is a smart tool allowing you to easily scan, review, and save; Stay organized easily with the help of this Epson scanner
- EASY SETUP — USB-powered connect to your computer for quick and simple scanning; No batteries or external power supply required to operate portable document scanner; Standard Connectivity: USB 2.0
Put the font files you are licensed to use in ./fonts. The page’s CSS must use the correct family name for those files.
FROM ghcr.io/puppeteer/puppeteer:latest
USER root
COPY ./fonts/ /usr/local/share/fonts/custom/
RUN fc-cache -fv
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
USER pptruser
CMD ["node", "render.js"]
This assumes the selected image provides the expected user, Node.js, Puppeteer dependencies, and font-cache command. If you build from a different base image, install the browser’s required OS dependencies and adapt the font-installation steps rather than assuming this Dockerfile transfers unchanged.
Install the project dependency
For a minimal project, create package.json with Puppeteer as a dependency, then run npm install to produce the lockfile used by npm ci in the image build.
{
"private": true,
"scripts": {
"render": "node render.js"
},
"dependencies": {
"puppeteer": "^24.0.0"
}
}
The version range is an example, not a compatibility guarantee. Pin and test the Puppeteer version and browser image you intend to deploy together.
Render the webpage and wait for the fonts
Save the following as render.js. It navigates to a URL supplied as the first argument, waits for the navigation, explicitly waits for document.fonts.ready, and writes a PDF. The explicit font wait makes the intent clear even though Puppeteer’s PDF option waitForFonts defaults to true.
Rank #2
- FAST SPEEDS - Scans color and black and white documents a blazing speed up to 16ppm (1). Color scanning won’t slow you down as the color scan speed is the same as the black and white scan speed.
- ULTRA COMPACT – At less than 1 foot in length and only about 1. 5lbs in weight you can fit this device virtually anywhere (a bag, a purse, even a pocket).
- READY WHENEVER YOU ARE – The DS-640 mobile scanner is powered via an included micro USB 3. 0 cable allowing you to use it even where there is no outlet available. Plug it into you PC or laptop and you are ready to scan.
- WORKS YOUR WAY – Use the Brother free iPrint&Scan desktop app for scanning to multiple “Scan-to” destinations like PC, Network, cloud services, Email and OCR. (2) Supports Windows, Mac and Linux and TWAIN/WIA for PC/ICA for Mac/SANE drivers. (3)
- OPTIMIZE IMAGES AND TEXT – Automatic color detection/adjustment, image rotation (PC only), bleed through prevention/background removal, text enhancement, color drop to enhance scans. Software suite includes document management and OCR software. (4)
const puppeteer = require('puppeteer');
async function main() {
const url = process.argv[2];
if (!url) {
throw new Error('Usage: node render.js <url> [output.pdf]');
}
const outputPath = process.argv[3] || 'page.pdf';
const browser = await puppeteer.launch({
// The official Puppeteer Docker image is designed to run Chromium sandboxed.
// Keep the image's required sandbox permissions configured at container launch.
});
try {
const page = await browser.newPage();
await page.goto(url, { waitUntil: 'networkidle2', timeout: 60000 });
// Wait for fonts declared through CSS and fonts available to the browser.
await page.evaluate(() => document.fonts.ready);
await page.pdf({
path: outputPath,
format: 'A4',
printBackground: true,
waitForFonts: true
});
console.log(`Saved ${outputPath}`);
} finally {
await browser.close();
}
}
main().catch((error) => {
console.error(error);
process.exitCode = 1;
});
networkidle2 is a navigation wait condition, not proof that every font or image rendered as intended. Pages with persistent connections or unusual loading behavior may need a different readiness condition, such as waiting for a page-specific selector. The explicit font-ready wait applies after navigation; if the page dynamically changes its content or font declarations afterward, wait for that application-specific work too.
Build and run the container
-
Build the image from the directory containing the Dockerfile,
package.json, lockfile,render.js, andfonts/:Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.docker build -t webpage-pdf . -
Run it with the sandbox permissions required by the Puppeteer Docker image, and use an init process to manage child processes:
docker run --init --rm --cap-add=SYS_ADMIN webpage-pdf https://example.com output.pdf -
Confirm that
output.pdfwas created and inspect pages where the custom font or special glyphs matter. Test with the actual URL, font files, and container runtime you plan to use.
The Puppeteer Docker guide describes sandbox operation, the SYS_ADMIN capability, and use of --init or an equivalent init process. Do not remove sandboxing or add broader privileges casually; match the runtime permissions to the image and your deployment’s security requirements.
Rank #3
- STAY ORGANIZED – Easily convert your paper documents into digital formats like searchable PDF files, JPEGs, and more.Power Consumption : 2.5W or less (Energy Saving Mode: 0.7W). Suggested Daily Volume : 500 scans..Does it contain liquid: no
- CONVENIENT AND PORTABLE –lightweight and small in size, you can take the scanner anywhere from home offices, classrooms, remote offices, and anywhere in between
- HANDLES VARIOUS MEDIA TYPES – Digitize receipts, business cards, plastic or embossed cards, reports, legal documents, and more
- FAST AND EFFICIENT – No technical hurdles or complicated setups here; easily scan both sides of a document at the same time, in color or black-and-white, at up to 12 pages-per-minute, and with a 20 sheet automatic feeder
- BROAD COMPATIBILITY – Works with both Windows and Mac devices, be it laptop or computer
Choose print or screen styling and tune the PDF
page.pdf() renders with print media by default. If the page should use its screen stylesheet instead, set the media type before generating the PDF:
Recommended Free Tools
await page.emulateMediaType('screen');
await page.pdf({ path: 'page.pdf', printBackground: true });
For a print-oriented PDF, leave print media selected and define print rules in the page’s CSS where you can. Puppeteer’s PDF options let you set paper format, margins, landscape orientation, page ranges, and whether backgrounds are printed. CSS page sizing can also affect the resulting layout, so check the page’s print styles alongside the PDF options.
Example PDF options
await page.pdf({
path: 'page.pdf',
format: 'A4',
landscape: false,
printBackground: true,
margin: {
top: '12mm',
right: '12mm',
bottom: '12mm',
left: '12mm'
},
// Optional examples:
// pageRanges: '1-3',
// preferCSSPageSize: true,
waitForFonts: true
});
Adjust paper size and margins for the document rather than treating these example values as required settings. If the page’s CSS specifies its own page size, decide whether that CSS or the PDF format option should govern the output.
Verify the rendered font, not just the PDF file
A successful call to page.pdf() confirms that Puppeteer produced a PDF; it does not establish that every intended font and glyph appeared correctly. Check the output visually, especially for headings, non-Latin scripts, symbols, and text that wraps near page boundaries.
- Check the family name: confirm the page’s
font-familymatches the installed font’s family or the name declared in@font-face. - Check glyph coverage: verify the chosen font includes the characters the page uses. Missing glyphs can fall back to another font even when the main face loaded.
- Check the browser can access the font: installed fonts must be visible to the Chromium process; CSS-loaded font files must be reachable and finish loading.
- Check print rules: PDF generation uses print media unless you explicitly emulate screen media, so screen-only font or layout rules may not apply.
- Check the deployed image: test the built container with the real browser version, fonts, page, and runtime permissions—not only on a developer machine.
Troubleshoot common failures
The PDF uses a fallback font
Check that the font files were copied into the image, that the font cache was refreshed if the distribution requires it, and that the browser process can see the installed faces. Verify the CSS family name and inspect whether the requested characters exist in the font.
Rank #4
- IRIScan Express, portable scanner : scans color and black and white documents a blazing speed up to 8ppm simplex. Color scanning won’t slow you down as the color scan speed is the same as the black and white scan speed.
- IRIScan Express mobile scanner is powered via an included micro USB 2. 0 cable allowing you to use it even where there is no outlet available. Plug it into you PC or laptop and you are ready to scan. USB cable provided. AC Adapter not provided and not needed.
- IRIScan flatbed scanner uses a simplex scanning mode allows for quick and straightforward scanning of single-sided documents. IRIScan with its full portable features is the ideal document scanners for computers.
- IRIScan document scanner : Versatile scanning capabilities, including scanning to Word, PDF, and Excel formats with companion software provided Readiris OCR
- Receipt scanner and card scanner with Additional features include scanning business cards directly to Outlook, photo scanning, and receipt scanning for efficient document management
A CSS-hosted font is missing in Docker
The browser may not be able to reach the font URL, or the request may not have completed before capture. Check the page’s network access and font-loading errors, then wait for document.fonts.ready after the page and its relevant content have loaded.
The PDF has the wrong layout or missing backgrounds
Remember that page.pdf() uses print media by default. Use page.emulateMediaType('screen') if you need screen styling; set printBackground: true when backgrounds should print. Review the page’s print CSS, paper size, margins, orientation, and any CSS page-size rules.
Chromium exits or fails to launch in the container
Check that the image’s required browser dependencies are present and that its sandbox permissions are configured correctly. The Puppeteer Docker guide specifies SYS_ADMIN for its documented sandboxed setup and recommends an init process such as Docker’s --init. Custom images can have different dependencies, so validate the exact image and runtime configuration.
Navigation times out or never becomes idle
A page may keep network activity open or may not become idle under the chosen wait condition. Check whether the page loaded and whether its fonts are accessible; for pages with ongoing requests, use a more appropriate navigation condition and wait for a meaningful selector or page-specific readiness signal before generating the PDF.
Free tools Windows power users keep installed
One-click scans. No signup required.
Or skip the browser setup
If you need a hosted capture rather than a Puppeteer container, ScreenshotNeo is a screenshot API and MCP server that can return a PDF. It does not give you a way to install your own fonts in a Dockerized Chromium process: the page’s fonts still need to be available to the hosted capture. For a page that already loads the desired fonts, its one-call request avoids maintaining the browser image.
Best Value
- Scanner type: Document
- Connectivity technology: USB
- With Auto Scan Mode, the scanner automatically detects what you're scanning
- Digitize documents and images
For example, this cURL request captures a webpage; see the ScreenshotNeo API documentation for the PDF and other capture options:
curl -G "https://api.screenshotneo.com/v1/shot"
-d access_key=YOUR_API_KEY
--data-urlencode url=https://example.com
-o shot.webp
ScreenshotNeo accepts and removes cookie-consent banners, newsletter popups, and chat widgets before capture, with each step able to be turned off. Bot checks, blank pages, failed loads, timeouts, and cache hits are not billed, and response headers report the page verdict and billing status. Its MCP server provides take_screenshot, get_page_info, and capture_pdf tools for AI agents and other MCP clients. The free plan includes 1,000 shots per month with no card; paid plans start at $5 for 3,000 shots.
Sign up for ScreenshotNeo’s free plan to try 1,000 screenshots a month with no card.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Frequently Asked Questions
Does Puppeteer wait for fonts before creating a PDF?
Yes. Puppeteer’s PDF option `waitForFonts` defaults to `true` and waits for `document.fonts.ready`; the example also waits for that promise explicitly.
Can I use custom fonts without installing them in Docker?
Yes, if you control the page, you can load the fonts through CSS such as `@font-face`. The browser container must be able to fetch those font files, and they must finish loading before capture.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




