To get web fonts into an HTML-to-PDF conversion, make the font files available to the renderer and wait for them to load before creating the PDF. With WeasyPrint, declare the font using @font-face, create a FontConfiguration, and pass it to both the CSS and PDF-writing calls. WeasyPrint documents that fonts are embedded and subset by default. With Playwright, remember that page.pdf() uses print CSS media by default, which can change the page’s styling.
Convert HTML with a web font using WeasyPrint
WeasyPrint can load a font through CSS or use a font installed and discoverable on the host. For a web font, the font URL must be reachable from the process generating the PDF. When using @font-face, use the same FontConfiguration instance for the stylesheet and HTML.write_pdf().
As an Amazon Associate I earn from qualifying purchases.
This example follows WeasyPrint’s documented pattern. It is illustrative rather than a tested recipe; confirm that your installed version and deployment support the font format and URL behavior you use.
from weasyprint import HTML, CSS
from weasyprint.text.fonts import FontConfiguration
font_config = FontConfiguration()
html = HTML(string='''
<!doctype html>
<html>
<body>
<h1>PDF with a web font</h1>
<p>This paragraph uses the declared font.</p>
</body>
</html>
''')
css = CSS(string='''
@font-face {
font-family: ExampleFont;
src: url("https://example.com/fonts/example.woff2");
}
body {
font-family: ExampleFont, sans-serif;
}
h1 {
font-weight: 700;
}
''', font_config=font_config)
html.write_pdf('output.pdf', stylesheets=[css], font_config=font_config)
Replace the example font URL with a real font file your renderer can access. Declare the family, style, and weight you intend to use, and make sure the CSS selects those faces. WeasyPrint’s API documentation says: “Fonts are automatically embedded in PDF files and are subset by default to only include the glyphs used in the PDF.”
#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
Use Playwright when the page needs a browser renderer
Playwright’s page.pdf() generates a PDF using print CSS media by default. If you want the page’s screen styling instead, call page.emulateMedia({ media: 'screen' }) before generating the PDF. The API also exposes page-size, margin, background-printing, and color controls.
Web-font loading involves at least two resources: the stylesheet is fetched first, then the font file. Make font readiness an explicit part of your capture flow, using the documented APIs available in your chosen browser runtime. The following example waits for the document’s font set before calling page.pdf(); verify that it behaves as expected with your installed Playwright and browser versions.
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 { chromium } = require('playwright');
(async () => {
const browser = await chromium.launch();
try {
const page = await browser.newPage();
await page.goto('https://example.com', { waitUntil: 'networkidle' });
await page.evaluate(() => document.fonts.ready);
// Optional: choose screen styling instead of the default print styling.
// await page.emulateMedia({ media: 'screen' });
await page.pdf({ path: 'output.pdf', format: 'A4', printBackground: true });
} finally {
await browser.close();
}
})();
Use the page’s own URL in page.goto(). The example waits for network idle and then for the document’s font set; for pages that keep network requests open, choose a navigation readiness condition suited to that page and still verify font loading before capture.
Choose a renderer for the document, not just the font
The available documentation establishes different strengths, not a performance winner. Choose based on the document’s CSS and JavaScript needs, font handling, pagination requirements, deployment environment, and how you will restrict access to resources.
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
| Decision point | WeasyPrint | Playwright |
|---|---|---|
| Font setup | Supports CSS @font-face with FontConfiguration; documents automatic font embedding and subsetting. |
Uses a browser page; font resources need to load before PDF capture. The reviewed Page API does not specify a dedicated font-loading option. |
| Media styling | Converts HTML and CSS using write_pdf(). |
page.pdf() uses print media by default; select screen media explicitly if that is the desired styling. |
| Page controls | The documented workflow supports @page CSS and PDF generation. |
The API exposes page dimensions, margins, page-size preference, backgrounds, and color controls. |
| Resource access | The guide warns that HTML and CSS can access local files and recommends restricting access for untrusted input. | Not established by the documentation reviewed here; assess browser sandboxing and request policy in your deployment. |
There is no head-to-head benchmark here. Test representative documents in the exact renderer versions and environment you plan to deploy, especially when page breaks, dynamic content, or particular glyphs matter.
Verify the generated PDF
A CSS declaration alone does not prove the PDF used the intended face. Check the actual output in the PDF reader and environment your users will rely on.
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
- Inspect representative text, including accented characters or other glyphs your document needs.
- Check that the intended font family, style, and weight appear rather than a fallback.
- Review line wrapping, page breaks, and page styling, particularly when moving between screen and print media.
Troubleshoot missing or incorrect fonts
- Text appears as squares or is missing in WeasyPrint: confirm the font is installed or correctly referenced with
@font-face, and that it contains the needed glyphs. - The font URL works in a browser but not in the renderer: test access from the machine or container running conversion. Network restrictions, certificates, authentication, or URL-fetching policy may prevent retrieval.
- A fallback face appears: compare the CSS
font-family, style, and weight with the declared@font-facerule and the actual font file. Inspect the PDF rather than relying on the page’s appearance in a browser. - Playwright’s PDF looks different from the page: check whether print media is active. Use
page.emulateMedia({ media: 'screen' })before PDF generation when screen styles are intended. - Fonts or other resources load inconsistently: make resource readiness part of the capture flow and check the resulting PDF in the target reader. A successful conversion call alone does not verify the output’s font coverage or layout.
Protect server-side conversion from untrusted input
WeasyPrint documents that HTML and CSS can access local files through file:// URLs. If users can submit HTML or CSS, treat those inputs and their referenced assets as security-sensitive. Restrict access to trusted files, and use a custom URL fetcher that blocks or filters protocols and paths, as the WeasyPrint guide recommends. Also decide which remote resources the rendering service is allowed to fetch.
Or skip the browser setup
If your goal is to capture a rendered website rather than control every detail of HTML-to-PDF font embedding, ScreenshotNeo is a website screenshot API and MCP server. Its one-call API can return a screenshot or a PDF; this example requests a WebP screenshot:
Best Value
- Scanner type: Document
- Connectivity technology: USB
- With Auto Scan Mode, the scanner automatically detects what you're scanning
- Digitize documents and images
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
See the ScreenshotNeo API documentation for request options, including PDF output. Cookie banners are accepted and removed before capture along with known newsletter popups and chat widgets. Bot checks, blank pages, failed loads, timeouts, and cache hits are not billed. Its MCP server lets AI agents use the take_screenshot, get_page_info, and capture_pdf tools. The free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000 shots.
Sign up for ScreenshotNeo’s free plan to get 1,000 screenshots a month with no card.
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.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.




