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
CSS

How to Fix Text Wrapping Problems in wkhtmltopdf

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

If text wraps differently, moves to another line, or gets clipped in a wkhtmltopdf PDF, do not start by stacking CSS fixes. First reproduce the problem in the PDF renderer, record the exact build and inputs, then isolate width, whitespace, font, and table context one change at a time. Reports in the wkhtmltopdf issue tracker show browser-to-PDF differences, but they do not establish one universal cause or CSS remedy.

Why wkhtmltopdf text wrapping differs from a browser

A browser preview is not proof that wkhtmltopdf will lay out the same HTML identically. Issue reports describe a last-word wrapping change associated by the reporter with an upgrade from version 0.9.9.3 to 0.12.2.1, as well as text clipped at the right edge in another case. These are individual reports, not controlled tests, so treat version, fonts, available width, and surrounding markup as variables to investigate rather than established general causes. Issue #2505 · Issue #4080

Wrapping depends on the space available to the text and the rules governing where it may break. A narrow table column, a long unbroken token, preserved whitespace, or a font with different metrics may produce a line break or clipping that was not apparent in the browser. Table nesting and page-break behavior can further complicate diagnosis. The practical goal is to find the smallest combination of markup, styles, renderer build, and conversion options that still shows the defect.

Build a minimal reproduction first

  1. Save both outputs. Keep the HTML and the PDF generated by wkhtmltopdf. Compare the affected passage at the same scale and note exactly what differs: an unexpected line break, a final word on a new line, clipped characters, or missing content.
  2. Reduce the document. Remove unrelated content until only the affected text and its immediate containers remain. Preserve the relevant CSS, table structure, fonts, and page settings; removing too much can make the symptom disappear.
  3. Record how it was rendered. Save the exact wkhtmltopdf version or build, operating system, font declarations, and command-line flags. If the output depends on external assets, retain the relevant HTML, CSS, and JavaScript needed to reproduce the page.
  4. Change one variable at a time. Adjust a width, font rule, whitespace setting, or table layer, then regenerate the PDF and record the result. Keep the minimal failing case even after finding a workaround.

This mirrors the project’s request that a bug report include a detailed description and a reproducing test case with HTML, CSS, and JavaScript. wkhtmltopdf support

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

Check width, whitespace, and break opportunities

Measure the actual text container

Inspect the width of the element containing the text and each parent that constrains it. In tables, check the table width and the affected column width, not just the cell’s own CSS. Look for fixed widths, percentage widths, padding, borders, and nested containers that leave less usable space than expected. Make one controlled adjustment at a time and check whether the same text now fits or wraps predictably.

Look for whitespace rules that prevent normal wrapping

Review the affected element and its ancestors for white-space declarations. A rule such as white-space: nowrap can suppress ordinary line breaks; preserved whitespace can also alter line layout. Test a change on the smallest relevant element rather than overriding whitespace across the whole document. Confirm that the change does not damage intentional spacing or other content.

Rank #2

Test long, unbroken strings separately

A long URL, identifier, or other token without spaces may not have an ordinary word boundary where the renderer can break a line. If that is the isolated trigger, test a suitable break opportunity in the content or an appropriate breaking declaration on the affected element. Do not assume word-wrap: break-word is a guaranteed fix: the report of right-side truncation in issue #4080 says that trying it did not resolve that reporter’s case.

Isolate fonts and version changes

Compare the font declarations in the failing case with a minimal version that omits or changes them. One issue reporter associated a last-word wrap change with an upgrade from wkhtmltopdf 0.9.9.3 to 0.12.2.1 and also reported a difference after removing Arial. Those observations make the build and font sensible test variables; they do not prove either is the cause in other documents. The report is in issue #2505.

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.

When testing fonts, change only the font declaration while keeping the text, width, and other CSS fixed. Record what font is declared and what the conversion environment can actually access. If changing the font changes the wrap, investigate font availability and metrics in the rendering environment before making broad layout changes.

Reduce nested tables and pagination complexity

If wrapping trouble appears in a table cell, reduce the table structure temporarily. Remove nested tables and nonessential styles, then add back one layer or rule at a time. Check widths, font rules, and page-break behavior independently. A project report describes pagination trouble involving nested tables and substantial text; its sample included pre-wrap and break-all, but those are details of the reported setup, not validated recommendations. Issue #4558

Distinguish line wrapping from page pagination. If text fits across a line but breaks or disappears around a page boundary, reduce the case to the table and content crossing that boundary, then test page-break rules separately from line-breaking rules. The project’s issue tracker also records a table/page-break report. Issue #3808

Use CSS experiments carefully

Avoid applying break-all, overflow: hidden, and broad white-space overrides together as a first response. They address different behaviors: breaking every character can damage word integrity, hidden overflow can conceal text, and whitespace changes can remove intended formatting. The reviewed project reports do not validate a universal combination. Start with the smallest relevant element and verify both the target passage and nearby content after each change.

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.
  • If a final word moves to the next line, verify the content width, font, and renderer build before forcing breaks.
  • If text runs beyond the right edge, inspect parent and table widths and whether normal wrapping is disabled; a reported attempt at word-wrap: break-word did not resolve one such case.
  • If only a long token overflows, test a deliberate break opportunity or a narrowly scoped breaking rule.
  • If the issue happens inside nested tables or near a page boundary, simplify table nesting and page-break rules before changing global text behavior.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshooting checklist

Symptom What to isolate Next test
A last word moves to a new line Available width, font declaration, and exact wkhtmltopdf build Reproduce with the same text and container; change one font or width variable at a time.
Text is clipped at the right edge Parent and column widths, padding, whitespace rules, and long tokens Check the usable width and test normal wrapping. Do not rely on word-wrap: break-word as a universal remedy.
Only table-cell content behaves incorrectly Nested tables, cell/column widths, font rules, and page breaks Remove nested structure temporarily, then restore one layer and rule at a time.
Browser looks right but PDF does not Renderer version/build and conversion environment Use the PDF as the failing output; capture the exact build, OS, font declarations, and flags.
A CSS workaround hides or distorts text Broad overflow, whitespace, or character-breaking overrides Remove stacked overrides and test a narrowly scoped change while checking adjacent content.

When a workaround is not worth maintaining

The wkhtmltopdf GitHub repository displays an archive notice dated January 2, 2023 and is read-only. That describes the upstream repository, not the state of every packaged binary, downstream fork, or deployment. If a reproducible wrapping defect remains costly to work around, weigh continued use against evaluating another HTML-to-PDF renderer. Compare the CSS and layout features your documents require, fidelity to existing PDFs, deployment environment, maintenance status, and migration and regression-test effort. The cited material does not establish a particular replacement or comparative benchmark, so the choice depends on your own documents and constraints. Repository archive notice shown on issue #3808

Or skip the browser setup

If your immediate need is a clean capture of a web page rather than debugging wkhtmltopdf’s HTML-to-PDF layout, ScreenshotNeo offers a website screenshot API and MCP server. Its one-call screenshot request is:

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 the request options. ScreenshotNeo accepts cookie/consent banners before capture and removes 60+ known consent platforms, newsletter popups, and chat widgets; each step can be turned off. Bot checks/CAPTCHAs, blank pages, timeouts, failed loads, and cache hits cost nothing, and response headers indicate the page verdict and whether the request was billed. Its MCP server offers take_screenshot, get_page_info, and capture_pdf for AI agents using Claude, Cursor, or another MCP client. The Free plan includes 1,000 shots per month without a card; paid plans start at $5 for 3,000 shots.

Sign up for 1,000 free screenshots a month, with no card required.

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

Frequently Asked Questions

Does changing `word-wrap` always fix clipped text in wkhtmltopdf?

No. One issue report says `word-wrap: break-word` did not fix that reporter’s right-edge truncation. Check the actual container width, whitespace rules, and markup context instead of treating it as a guaranteed fix.

Is the wkhtmltopdf project still maintained upstream?

The GitHub repository displays an archive notice dated January 2, 2023 and is read-only. That notice does not establish the status of every package or downstream fork.

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
Windows Errors? Fix Them Before They SpreadFree repair scan
Crashes, No Sound, or Screen Glitches?Free driver scan

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.