Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Define the font and background in the HTML/CSS that you convert, then make every stylesheet and font file readable by the wkhtml runtime. For PDFs, keep --background enabled (it is the documented default), and use --print-media-type only when you want print CSS. Do not use that switch to fix an image capture: the library settings explicitly state that print-media selection has no effect on wkhtmltoimage.

Start with HTML that contains the design

wkhtmltopdf and wkhtmltoimage render a web document; they do not install a font or invent a background for you. Put both in the page or in a stylesheet that the converter can load.

<!doctype html>
<html>
<head>
  <meta charset="utf-8">
  <style>
    @font-face {
      font-family: "ReportSans";
      src: url("fonts/report-sans.woff2") format("woff2");
      font-weight: 400;
      font-style: normal;
    }

    html, body {
      margin: 0;
      padding: 0;
      background: #10243b;
    }

    body {
      color: #f4f7fb;
      font-family: "ReportSans", Arial, sans-serif;
      font-size: 16px;
    }

    .sheet {
      min-height: 100vh;
      padding: 48px;
      box-sizing: border-box;
      background: #10243b;
    }

    @media print {
      .screen-only { display: none; }
    }
  </style>
</head>
<body>
  <main class="sheet">
    <h1>Quarterly report</h1>
    <p>The background and font are part of the document being rendered.</p>
  </main>
</body>
</html>

Using both html and body for the background avoids a common layout surprise: a child element can cover the body’s color, and a page with no content-height rule may not paint as far as you expect. For a full-page design, give the principal container an explicit background and enough height for the output you need.

The @font-face declaration is only a reference. The converter must be able to read the file, and the particular wkhtml build and operating system must be able to decode that font. The official settings documentation does not promise universal support for every font format or operating-system combination, so verify the exact runtime you deploy rather than assuming that a browser-supported file will work identically.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Sale
Epson EcoTank ET-2800 Wireless Color All-in-One Supertank Printer - Black
  • INNOVATIVE CARTRIDGE-FREE PRINTING — No more dealing with lots of tiny ink cartridges; With this wireless document and photo printer each ink bottle set is equivalent to about 90 individual cartridges²
  • LESS FREQUENT INK REPLACEMENT — Replacement ink bottles don't have to be changed nearly as often as ink cartridges¹; When you choose this combination printer, scanner and copier you can print up to 4,500 pages black/7,500 color³
  • COLOR PRINTING — Up to 2 years of ink in the box4 (and with every replacement ink set) for fewer out-of-ink frustrations
  • ZERO CARTRIDGE WASTE — By using an Epson EcoTank printer you can help reduce the amount of cartridge waste ending up in landfills
  • HOME PRINTER DESIGNED FOR RELIABILITY — The Epson EcoTank ET-2800 All-in-One Supertank Color Printer creates vivid, detailed prints and documents thanks to Micro Piezo Heat-Free Technology; Fire off 10 ISO pages per minute1 to easily finish large jobs

Generate a PDF with a background and custom font

Basic conversion

The simplest command is:

wkhtmltopdf --background input.html report.pdf

The usage manual describes --background as “Do print background (default).” Supplying it explicitly makes the intention clear and protects the command from a wrapper or script that adds --no-background. If a background is missing, inspect the final command line first; --no-background disables background printing.

wkhtmltopdf --no-background input.html report-without-color.pdf

Allow local stylesheets and fonts

When the HTML refers to a local stylesheet, font, image, or other file, use the documented --allow option to grant access to the required directory. Keep the permission as narrow as possible:

wkhtmltopdf 
  --background 
  --allow /srv/reports/site 
  /srv/reports/site/input.html 
  /srv/reports/output/report.pdf

The path in --allow must contain the referenced resources. If the CSS says url("fonts/report-sans.woff2"), a file at /srv/reports/site/fonts/report-sans.woff2 is permitted by the example above. A permission for a different directory does not make the font visible.

Inject a user stylesheet

If you cannot edit the source HTML, pass a stylesheet with --user-style-sheet:

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
wkhtmltopdf 
  --background 
  --user-style-sheet /srv/reports/print-overrides.css 
  --allow /srv/reports 
  input.html report.pdf

Use this for deliberate overrides, such as setting a page background or replacing a web font declaration. It does not remove the need to make any font file referenced by that stylesheet accessible.

Choose screen or print CSS

wkhtmltopdf uses screen media by default. Add --print-media-type when the document’s @media print rules are the design you want in the PDF:

wkhtmltopdf 
  --background 
  --print-media-type 
  --allow /srv/reports/site 
  input.html report-print-css.pdf

This choice can change the font, colors, visibility, and backgrounds selected by your CSS. It is independent of whether the font file itself is readable. A valid font under screen rules can still fall back under print rules if the print stylesheet selects another family or overrides the declaration.

Rank #2
Sale
Epson EcoTank Photo ET-8550 Wireless Wide-Format All-in-One Tank Printer
  • CARTRIDGE-FREE PRINTING — Print lab-quality photos, graphics and creative projects; Get vibrant colors and sharp text with Epson's high-accuracy printhead and Claria ET Premium 6-color inks
  • INK BOTTLES — Save on photos1 and creative projects with affordable in-house printing; All-in-one printer allows you to print 4" x 6" photos for about 4 cents each vs. 40 cents with traditional ink cartridges1
  • LESS FREQUENT INK REPLACEMENT — Replacement ink bottles don't have to be changed nearly as often as ink cartridges¹; Printer, scanner and copier lets you print up to 6,200 color pages³
  • PRINT FOR LONGER — Up to 2 years of ink in the box² (and with every replacement ink set) for fewer out-of-ink frustrations with this wireless printer
  • ZERO CARTRIDGE WASTE — Epson EcoTank printer helps reduce the amount of cartridge waste ending up in landfills; Cartridge-free printer uses high-yield ink bottles; Each replacement ink bottle set is equivalent to about 100 individual ink cartridges⁴

Load a page stylesheet from a URL

A stylesheet served from the same site as the document avoids local-file permission issues, provided the conversion host can reach it. For reproducible builds, local assets plus an explicit --allow directory make the dependency visible in the command and remove a network dependency.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Render an image with wkhtmltoimage

Basic image conversion

wkhtmltoimage input.html report.png

CSS backgrounds are part of the page that is painted into the image. Keep the background declarations in the HTML or an accessible stylesheet, and make the font URL readable just as you would for a PDF. If your build accepts the access-control option, grant the asset directory explicitly:

wkhtmltoimage 
  --allow /srv/reports/site 
  input.html report.png

Check the help output of the binary you deploy because option availability can vary by build. Do not add --print-media-type as an image fix. The library settings reference says that load.printMediaType “has no effect for wkhtmltoimage.” If the image should look different, change the screen CSS, the document’s selectors, or the viewport and layout settings supported by your particular binary instead.

PDF and image behavior at a glance

Question wkhtmltopdf wkhtmltoimage
Output PDF Raster image such as PNG, subject to the formats supported by the build
Background control --background prints backgrounds and is documented as the default; --no-background disables them Paint the CSS background in the page; there is no useful print-media switch for image rendering
Media selection Screen media is default; --print-media-type selects print media The library’s load.printMediaType setting has no effect
Local resources Use an accessible URL or grant the needed directory with --allow Use an accessible URL or the corresponding access control supported by your build

Make custom fonts dependable

Use a deterministic path

Resolve relative URLs from the document’s location, not from the shell’s current directory. If a generated HTML file is in /srv/reports/site/input.html, a declaration such as url("fonts/report-sans.woff2") points beneath that directory. Use an absolute file URL only when your deployment and security policy allow it, and then grant access to its parent directory.

Check the computed family and weight

A fallback can look like a missing font even when the file loaded. Match the CSS family name, weight, and style to the declarations in @font-face. For example, requesting font-weight: 700 while defining only a 400 face can cause synthetic bolding or a different face. Define each weight you actually use, or deliberately request the weight that exists.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Do not assume a format guarantee

The cited project documentation exposes stylesheet and file-access controls, but it does not publish a universal font-format compatibility matrix. A file that works in a current desktop browser may fail in an older or differently patched Qt/WebKit build. Test the exact binary, operating system, and font files used in production; keep a fallback family so text remains legible if the custom face cannot load.

Keep encoding explicit

Set <meta charset="utf-8"> and save the HTML and CSS in that encoding. The library settings also expose a default-encoding control. Incorrect encoding can make a font appear faulty when the actual problem is that the text was decoded incorrectly.

Rank #3
HP Smart Tank 5000 Ink Tank Printer | 2 Years of Ink Included | All-in-One
  • SET IT UP ONCE AND PRINT WITH CONFIDENCE. No complicated maintenance. Just easy, reliable printing you can count on.
  • INK FOR YEARS. NOT MONTHS. Up to 2 years of ink included. Get thousands of pages of cartridge-free printing. More pages, less hassle
  • KEEPS PRINTING WELL AFTER COMPETITORS HAVE QUIT. No complex maintenance. Sharper text, richer colors.[2] Only with HP Smart Tank
  • PREMIUM SUPPORT - Strong technical expertise to solve issues faster
  • THE LAST PRINTER YOU'LL EVER NEED. Enjoy years of refillable, cartridge-free printing.

Background colors, images, and print rules

Set the background on the element that owns the visible area

For a card, set the color on the card. For a full sheet, set it on a full-height wrapper as well as, if appropriate, the root elements. A background on an element with no painted area will not fill the page around its children.

Remember that print CSS can override the color

With the default screen media, rules inside @media print are not selected. With --print-media-type, they are. Inspect both rule sets for declarations such as background: white, background-color: transparent, or a print-only font family.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Separate PDF background policy from CSS

There are two independent gates for a PDF background: CSS must specify a background, and wkhtmltopdf must be allowed to print it. A correct CSS declaration still produces a white page when --no-background is present. Conversely, --background cannot create a color that the page never declared.

Troubleshoot missing fonts and colors

The PDF is white but the browser preview is colored

  • Search the actual command for --no-background and remove it or add --background.
  • Check whether --print-media-type activates a print rule that removes the background.
  • Confirm that the colored element has a real painted height and is not covered by an opaque child.

The font falls back

  • Verify the relative URL from the HTML file’s directory.
  • Grant the directory containing the font with --allow, or serve the resource from a reachable URL.
  • Check the family, weight, and style names in @font-face against the declarations that use them.
  • Try a fallback stack and test the exact build; the official documentation does not guarantee every font format.

The image ignores the print design

This is expected if you relied on --print-media-type. That setting does not switch wkhtmltoimage to print media. Move the required rules into the screen stylesheet or use selectors that apply to the image-rendering path.

Styles or fonts load inconsistently

Reduce the problem to one HTML file and one asset directory, then run with an explicit --allow path. The library settings expose controls for image loading, JavaScript, minimum font size, default encoding, and load-error behavior; differences in any of these between machines can change the rendered result. Record the binary version, operating system, command line, and asset paths with the build so a successful local run can be reproduced.

The PDF content is unexpectedly shrunk

As a layout diagnostic, test --disable-smart-shrinking:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
wkhtmltopdf 
  --background 
  --disable-smart-shrinking 
  input.html diagnostic.pdf

The manual describes this option as disabling WebKit’s strategy for making the pixel/DPI relationship non-constant, and identifies it as available only with patched Qt. If your binary lacks that patch, the option may be unavailable; treat the result as a build issue rather than a CSS conclusion.

Rank #4
Sale
NDYIN Portable Printers Wireless for Travel, N80 Bluetooth Thermal Printer
  • Wireless Bluetooth Printer: Portable thermal printer compatible with iPhone, Android phones, iPad and tablet computers via Bluetooth. For smartphones, please download the "Nada Print" App. You can also connect to laptops and computers for printing using a USB-C cable. (Note: Laptops and computers can only be connected via USB and require the installation of a driver first. Bluetooth connection is not supported.)
  • No-ink printing: Only supports US Letter and A4 size thermal paper.(Doesn't support regular paper) The no-ink portable thermal printer uses direct thermal technology, requiring no ink, toner or ribbons, making it environmentally friendly, cost-effective and time-saving. The thermal printer package comes with a roll of US Letter thermal printing paper. Note: When installing the paper, remember to switch the paper size switch on APP
  • Clear Print: NDYIN N80 portable thermal printer adopts high-definition printing technology, with a 203DPI resolution to provide you with clear printing results. This mobile printer is compatible with roll paper, folded paper and tattoo transfer paper, supporting printing from your mobile phone PDF, Word, pictures and web pages anytime and anywhere. It is recommended to use our NDYIN thermal paper to achieve good printing quality
  • Portable wireless printer for travel: The thermal printer is equipped with a built-in 1500mAh rechargeable battery, which can print 160 sheets of 8.5" x 11" thermal paper after being fully charged. It weighs only 1.5 pounds and is compact in size. This ink-free portable printer can be easily carried in a backpack or briefcase! It is perfect for business travel, cars, small offices, construction sites, schools and homes. You can print documents, contracts, invoices and boarding passes anytime and anywhere
  • The N80 thermal printer has a wide range of uses. The package includes the N80 printer, a roll of US Letter paper(7m/roll), a user manual, a guide card, a type-C soft cable and a type C adapter. Note: The charging adapter is not included. Special thermal paper is required for use; ordinary paper cannot be used. This ink-free portable thermal printer is suitable for various scenarios such as home, school, travel, office, and outdoor, meeting the printing needs of different groups of people. This tattoo template printer is also compatible with tattoo transfer paper, making it an ideal choice for tattoo art

The converter reports a load failure

Check the URL or file path first, then permissions and network reachability from the conversion host. A browser on your workstation may see an asset that the server-side process cannot. Use the documented load-error behavior and resource controls in your build to determine whether a missing asset should fail the conversion or be tolerated, and fix the underlying path whenever the font or background is required.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Performance and reproducibility checklist

  • Bundle the HTML, CSS, fonts, and images under a known directory for builds that must work offline.
  • Use one narrowly scoped --allow directory rather than granting an entire filesystem tree.
  • Choose screen or print media intentionally for PDFs and never rely on print-media selection for images.
  • Keep an explicit background policy in scripts: add --background for PDFs and avoid accidentally appending --no-background.
  • Log the wkhtmltopdf or wkhtmltoimage build, operating system, command line, and input revision.
  • Compare a known text sample and a known color swatch after upgrades; font fallback and CSS changes can be visually subtle.
  • When a layout is compressed, test smart shrinking only if the deployed binary has the patched-Qt option.

Or skip the browser setup

ScreenshotNeo provides a website screenshot API when you would rather not maintain a local wkhtml runtime. One GET request returns a PNG, JPEG, WebP, or PDF:

API documentation

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

Equivalent requests are useful when the capture is part of an application:

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
import requests

r = requests.get(
    "https://api.screenshotneo.com/v1/shot",
    params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"},
    timeout=90,
)
r.raise_for_status()
open("shot.webp", "wb").write(r.content)
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
if (!res.ok) throw new Error(`Screenshot failed: ${res.status}`);
const fs = await import('node:fs/promises');
await fs.writeFile('shot.webp', Buffer.from(await res.arrayBuffer()));

Before the capture, ScreenshotNeo accepts the cookie or consent banner like a visitor and removes more than 60 known consent platforms, newsletter popups, and chat widgets; each step can be turned off. Bot checks and CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed as clean shots, and the response identifies the result with X-Page-Verdict and X-Billed headers. An MCP server exposes take_screenshot, get_page_info, and capture_pdf for Claude, Cursor, and other MCP clients.

You can also set custom CSS or JavaScript, wait for a selector, delay, or network idle, load lazy images in full-page captures, choose a device or viewport, use dark mode and retina scale, select an element by CSS selector, hide selectors, block ads or requests, provide headers, cookies, a user agent, Authorization, timezone, or geolocation, resize images, cache with a chosen TTL, create signed links, submit asynchronous jobs with signed webhooks, capture up to 100 URLs per bulk call, and use the usage API or OpenAPI specification. Parameter names used by other screenshot APIs also work, which can simplify a migration.

The free plan includes 1,000 screenshots a month with no card. Paid plans start at $5 for 3,000 shots; every feature is included on every plan. Create a free ScreenshotNeo account to try it.

FAQ

Does --background install or embed a font?

No. It controls PDF background printing only. Font selection still depends on CSS, file access, and the capabilities of the specific wkhtml build.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Should I use print media for a PNG?

No. The documented load.printMediaType setting has no effect for wkhtmltoimage, so design the image path with screen rules and accessible resources.

Frequently Asked Questions

Does --background install or embed a font?

No. It controls PDF background printing only. Font selection still depends on CSS, file access, and the capabilities of the specific wkhtml build.

Should I use print media for a PNG?

No. The documented load.printMediaType setting has no effect for wkhtmltoimage, so design the image path with screen rules and accessible resources.

Quick Recap

Bestseller No. 3
HP Smart Tank 5000 Ink Tank Printer | 2 Years of Ink Included | All-in-One
HP Smart Tank 5000 Ink Tank Printer | 2 Years of Ink Included | All-in-One
PREMIUM SUPPORT - Strong technical expertise to solve issues faster; THE LAST PRINTER YOU'LL EVER NEED. Enjoy years of refillable, cartridge-free printing.
$194.03

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.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.