Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan Now×
Skip to content
Calc

How to Fix CSS calc() Not Working in wkhtmltopdf 0.12.4

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.

If width: calc(100% / 5) works in Chrome but not in wkhtmltopdf 0.12.4, the dependable fix is to calculate the value before rendering and send wkhtmltopdf ordinary CSS, such as width: 20%. Version 0.12.4 uses an old Qt WebKit engine, and its project status page says the embedded WebKit has not been updated since 2012. A fallback declaration can preserve the layout when a renderer ignores calc(), but a vendor prefix cannot supply a missing CSS feature.

Why calc() fails in wkhtmltopdf 0.12.4

wkhtmltopdf 0.12.4 renders HTML through an old Qt WebKit engine rather than a current Chrome engine. The wkhtmltopdf project status page says the WebKit used by the project has not been updated since 2012: wkhtmltopdf project status. An upstream issue reports CSS3 properties, including calc(), not rendering correctly in wkhtmltopdf: issue #4092.

That explains why a declaration may work in a current browser and be ignored or rendered incorrectly by 0.12.4. It is a renderer limitation, not necessarily an error in the arithmetic or a stylesheet syntax problem. However, first verify the stylesheet is loaded and that the minimal failing case reproduces; asset-loading problems can look like unsupported CSS.

Use a precomputed value for a reliable fix

Move the arithmetic into SCSS or application code, then emit a concrete value in the CSS that wkhtmltopdf receives. For five equal columns, each column is 20% of the available width, so the renderer does not need to evaluate division.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
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

SCSS example

$column-width: 20%;

.card {
  width: $column-width;
}

Compile the SCSS before generating the PDF. The resulting CSS should contain the ordinary declaration .card { width: 20%; }, not an unevaluated expression the PDF renderer must interpret. The exact-title Stack Overflow report describes an SCSS approach that worked in both the browser and the wkhtmltopdf report: Stack Overflow: How to make CSS calc work with wkhtmltopdf.

Generate CSS from application data

If the number of columns is configurable, calculate the percentage in the code that builds the page and write the result into a stylesheet or inline style. For example, with five columns:

column_count = 5
column_width = 100 / column_count
css = f".card {{ width: {column_width}% }}"

This Python snippet illustrates the calculation; integrate it into your own template-building step and ensure the generated output is valid CSS. For dimensions involving pixels, calculate using the actual available width and account for padding, borders, and gaps. A percentage width alone may not equal one-fifth of the rendered row if the box model or spacing adds extra width.

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⁴

Keep a fallback for mixed browser and PDF output

.card {
  width: 20%;
  width: calc(100% / 5);
}

A browser that supports the second declaration can use it; a renderer that ignores it may retain the earlier 20% declaration. The fallback is useful only if the first declaration is correct for the intended layout. It does not make calc() work in wkhtmltopdf. Test the actual PDF output, since support varies by rendering engine and version.

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

Does -webkit-calc() fix the problem?

You can briefly test -webkit-calc() as a diagnostic, but do not rely on it as the fix. A prefix changes the spelling of a CSS function; it cannot add a parser or evaluator that is absent from the embedded WebKit. If a prefixed expression fails in 0.12.4, replace it with a value computed before rendering or consider a renderer with CSS support suited to the document.

Diagnose the failure before changing the PDF pipeline

  1. Confirm the binary and environment. Run wkhtmltopdf --version and record the operating system. The version and OS help distinguish an engine limitation from differences in deployment or assets.
  2. Reduce the page to one element and one declaration. Reproduce with a minimal HTML file containing a single element styled with width: calc(100% / 5). Remove unrelated layout rules, scripts, and fonts until the result is clear.
  3. Try a concrete fallback first. Put width: 20% before the calc() declaration, generate a PDF, and compare it with the expression-only version. If the fallback works but the expression does not, that is consistent with unsupported calc().
  4. Verify the stylesheet is present. Temporarily add an obvious style such as a bright background color or fixed width. If that style is missing too, investigate how the stylesheet is linked or loaded before concluding that calc() is the cause.
  5. Separate stylesheet loading from engine behavior. Try an inline style or the documented --user-style-sheet option to load a small test stylesheet: wkhtmltopdf command-line usage. If ordinary CSS loads but calc() still fails, the rendering engine is the more likely explanation.
  6. When escalating, include a minimal reproduction. Provide the exact wkhtmltopdf version, operating system, and the smallest HTML, CSS, and JavaScript case that demonstrates the issue, following the project’s support guidance: wkhtmltopdf support.

What wkhtmltopdf options can—and cannot—change

Options can help isolate layout conditions or ensure the page is loaded as intended; they do not upgrade the CSS engine. The documented command-line options include --user-style-sheet for an additional stylesheet, --viewport-size for the viewport dimensions, and --run-script for JavaScript execution. Smart-shrinking controls can also affect the final printed scale. Check the usage reference for the syntax and behavior of options supported by your installed version: wkhtmltopdf usage reference.

Rank #3
HP Smart Tank 5000 Wireless All-in-One Ink Tank Printer, Scanner, Copier with 2 Years of Ink Included, Best-for-Home, Cartridge-Free, Refillable and AI-Enabled. (5D1B6A)
  • 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.
  • Use --user-style-sheet to test whether stylesheet loading is responsible.
  • Use --viewport-size when the layout depends on viewport width; verify that your test uses the same viewport as production.
  • Use --run-script only when page setup genuinely depends on JavaScript; it does not make unsupported CSS functions available.
  • Check smart shrinking if the PDF’s overall scale or widths differ from expectations. It can affect output dimensions, but it is not a remedy for a missing calc() implementation.

When to upgrade or migrate

The downloads page lists wkhtmltopdf 0.12.4 as an archived release dated November 22, 2016, and identifies 0.12.6 as the stable series released June 11, 2020. It also says obsolete releases are not accepted for bug reports: wkhtmltopdf downloads. Moving from 0.12.4 to 0.12.6 may be appropriate for other reasons, but do not assume it will add the particular CSS behavior your layout needs; validate a representative PDF with the target version.

The project’s status page describes the underlying engine as outdated and recommends evaluating WeasyPrint or Prince for controlled report generation, and Puppeteer for pages that depend on dynamic JavaScript. Select based on the document rather than on a single CSS feature:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • Static, CSS-focused reports: evaluate WeasyPrint or Prince and check the CSS and pagination behavior against representative documents.
  • Pages that depend on live application JavaScript: evaluate Puppeteer and confirm that scripts, fonts, network resources, and print styles finish loading before PDF capture.
  • Existing wkhtmltopdf deployment: if its output is otherwise acceptable and the layout can be expressed with precomputed CSS, retaining the current pipeline may be the lowest-change option.

Compare CSS feature coverage, JavaScript execution, pagination and print fidelity, and deployment complexity or operating cost. The best choice depends on your own templates and runtime requirements; no single migration is guaranteed to preserve every existing PDF pixel-for-pixel.

Rank #4
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
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

For a screenshot of a web page rather than a generated PDF report, ScreenshotNeo provides a website screenshot API and MCP server for developers. Its one-call API returns an image or PDF; for this example, request a WebP screenshot:

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 parameters and response details. Cookie and consent banners, newsletter popups, and chat widgets are removed before capture; those steps can be turned off. Bot checks, blank pages, failed loads, timeouts, and cache hits are not billed, and the response identifies the page verdict and billing status in headers. Its MCP server offers take_screenshot, get_page_info, and capture_pdf tools for AI agents. The free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000 shots. It captures web pages, so it is not a substitute for converting a locally generated report when that is what your workflow requires.

Sign up free for ScreenshotNeo to get 1,000 screenshots a month with no card.

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

Troubleshooting quick reference

Symptom Likely cause Next action
Chrome lays out the columns, but wkhtmltopdf does not The embedded WebKit does not handle the calc() expression as the browser does. Compute the width at build time and emit a concrete CSS value.
Neither the fallback nor calc() style appears The stylesheet may not be loading, or the selector may not match. Test an obvious style, then isolate stylesheet loading with inline CSS or --user-style-sheet.
The fallback works but the PDF columns still overflow The percentage may not account for padding, borders, gaps, or the container width. Calculate using the rendered content width and check the box model and spacing.
The PDF looks scaled or widths differ at another viewport Viewport or smart-shrinking settings may affect layout and print scale. Record and align viewport and shrinking options, then rerun the minimal test.
A prefixed expression behaves the same A vendor prefix cannot supply a missing implementation. Use precomputed CSS or evaluate another renderer against the full document.

Frequently Asked Questions

Is wkhtmltopdf 0.12.4 the same as the current Chrome rendering engine?

No. It uses an old Qt WebKit engine, which is why browser support for a CSS feature does not establish support in this PDF renderer.

Will upgrading from 0.12.4 to 0.12.6 guarantee calc() support?

The cited downloads page identifies 0.12.6 as the stable series, but the evidence here does not establish that upgrading guarantees correct calc() output. Test your own document with the version you plan to deploy.

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

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

Read next

Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.