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

There is no single, confirmed wkhtmltopdf switch that fixes every `text-align: justify` failure. Justification problems reported by users include overlapping text and unusually large gaps or spaces inside words. Start with a minimal reproduction, verify the exact wkhtmltopdf build and fonts, inspect line endings and whitespace, and compare the result with a current browser. Use the workarounds below to identify the cause before changing your production renderer.

What “broken” justification can mean

wkhtmltopdf uses Qt WebKit rather than the layout engine in a current Chrome, Firefox or Safari release. Consequently, the same HTML and CSS can produce different line breaks, glyph widths and justification spacing in a PDF. The project’s repository was archived on January 2, 2023, and its status material describes the bundled Qt and WebKit code as old.

Two frequently cited issue reports describe different symptoms:

Symptom What the report establishes What it does not establish
Overlapping text with `text-align: justify` One user reported that removing a CRLF between words fixed that particular example. Changing alignment to `left` also avoided the overlap. It does not prove that CRLF causes every overlap or that left alignment is a universal fix.
Extra space inside words Another user described inserted extra spacing in words, using a custom Thai font and a 0.12.5-era build. The report does not prove that the font, language or a particular CSS declaration is the root cause.

Treat these as diagnostic evidence, not as a single upstream bug with one guaranteed remedy.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
PDF Extra Lifetime - Professional PDF Editor - Best Adobe Acrobat Pro Alternative - Lifetime License for Windows PC
  • Perfect Adobe Acrobat Pro alternative – lifetime license for Windows 10 and 11.
  • EDIT text, images, pages, hyperlinks, designs in PDF documents. ORGANIZE PDFs.
  • READ and Comment on PDFs – Intuitive reading modes & document commenting and mark up tools!
  • CREATE, COMBINE, SCAN and COMPRESS PDFs.
  • FILL forms & Digitally Sign PDFs. Work with Digital certificates

1. Record the renderer before changing CSS

Run the binary that actually generates your PDF:

wkhtmltopdf --version

Save the complete output, operating system and distribution, page-size and DPI arguments, and whether the output says with patched qt. The official downloads page identifies 0.12.6 as the stable series released June 11, 2020, but builds can differ because Qt is packaged differently by vendors and distributions. A result from a system package is not necessarily equivalent to a downloaded static binary with the same version number.

  • Record the exact executable path (for example, the result of which wkhtmltopdf).
  • Capture the command line used by your application, including --page-size, margins, zoom, DPI and smart-shrinking options.
  • Reproduce in the same container, virtual machine or server image used in production.

2. Build a minimal reproduction

Remove templates, JavaScript widgets and unrelated styles until only one affected paragraph remains. Keep the same page width, font declarations, language and encoding as the failing document.

<!doctype html>
<meta charset="utf-8">
<style>
  @page { size: A4; margin: 20mm; }
  body { width: 170mm; font-family: Arial, sans-serif; font-size: 12pt; }
  p { text-align: justify; }
</style>
<p>Replace this sentence with the exact paragraph that overlaps or develops unusual spacing in your document. Keep the original whitespace while testing.</p>

Render that file with the target binary, then open the same HTML in a current browser and compare a print-to-PDF result. This comparison is not a standards test; it isolates whether the behavior is specific to the old WebKit renderer, your source text, or both.

3. Inspect line endings and invisible whitespace

Look at the paragraph source, not only its visual appearance. Check for:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • CRLF sequences embedded between words or at unexpected wrap points;
  • repeated ordinary spaces, tabs and non-breaking spaces;
  • zero-width characters and other unusual Unicode whitespace;
  • mixed encodings or a missing or incorrect <meta charset> declaration;
  • server-side template output that inserts a newline in the middle of a word or inline element.

In the overlap report, the user says deleting one CRLF between words removed the overlap. Test that change in a copy of the minimal file. If it works, normalize the data at its source rather than blindly removing every newline from every document; whitespace can be meaningful in preformatted or multilingual content.

Rank #2
MixPad Free Multitrack Recording Studio and Music Mixing Software [Download]
  • Create a mix using audio, music and voice tracks and recordings.
  • Customize your tracks with amazing effects and helpful editing tools.
  • Use tools like the Beat Maker and Midi Creator.
  • Work efficiently by using Bookmarks and tools like Effect Chain, which allow you to apply multiple effects at a time
  • Use one of the many other NCH multimedia applications that are integrated with MixPad.

For a quick inspection on Unix-like systems, make invisible characters visible:

sed -n 'l' reproduction.html

In application code, log the paragraph as a Unicode-aware escaped string and compare the bytes before and after templating. Do not assume that two visually identical spaces are the same code point.

4. Verify fonts, language and encoding

Justification depends on measured glyph widths. Confirm that the intended font is installed on the machine running wkhtmltopdf and that it is actually loaded before rendering. A browser on your workstation may silently substitute a font that is absent on the server.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • Install the required font files in the renderer’s environment and restart any service that caches font information.
  • Use a font family with the required Thai or other script coverage; verify the fallback chain explicitly.
  • Declare UTF-8 in the document and ensure your HTTP response or local file is encoded consistently.
  • Wait for web fonts before capture if your integration loads them dynamically; otherwise, the fallback font can determine line breaks.

The spacing report’s custom Thai font is an important variable to test, but it is not proof that the font caused the defect. Compare the exact font, a known system font and a version with justification disabled.

5. Use left alignment as a diagnostic workaround

Temporarily change the rule to:

p { text-align: left; }

The overlap report says this avoided its symptom. If left alignment fixes the PDF, the failure is associated with the justification path or the measurements it receives. This workaround sacrifices the even right edge, so use it only when that trade-off is acceptable. It is a useful production fallback for a small class of paragraphs, not evidence that every document should abandon justified text.

Rank #3
Sale
Adobe Acrobat 6 PDF For Dummies
  • Used Book in Good Condition

You can also scope the fallback to content known to trigger the problem:

.pdf-safe-paragraph { text-align: left; }
.pdf-safe-paragraph * { word-spacing: normal; letter-spacing: normal; }

Do not add arbitrary negative letter-spacing or word-spacing values to hide overlap. Such adjustments are font- and line-length-dependent and can make other pages worse.

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

6. Test page scaling separately

The --disable-smart-shrinking option disables WebKit’s intelligent shrinking strategy. The official usage documentation explains that smart shrinking affects the pixel/DPI relationship; it does not claim that disabling it fixes justification.

Run controlled comparisons:

wkhtmltopdf --page-size A4 input.html default.pdf
wkhtmltopdf --page-size A4 --disable-smart-shrinking input.html no-shrink.pdf

Keep every other setting identical and record DPI, zoom, page size and margins. If line breaks change, the original issue may be a scale or available-width problem rather than a text-align defect. If only glyph spacing changes while the paragraph width remains constant, continue investigating fonts, whitespace and the build.

7. Compare builds and decide whether to migrate

If the minimal file still fails, test another wkhtmltopdf build and document the result. Compare patched-Qt status, package source, operating system and font installation—not just the version string. A build change can alter behavior without changing your HTML.

Rank #4
Scrivar PDF Pro - Organize, Edit, Compress, Convert, Merge, eSign, OCR & 30+ tools | Lifetime License
  • EVERY PDF TOOL UNLOCKED - 30+ tools in one app: edit text and images, convert, merge, split, compress, sign, OCR, redact, watermark, batch process, and more. No feature gates, no upsells, nothing held back.
  • PAY ONCE, OWN FOREVER — A one-time purchase, not a subscription. Other apps runs $240/year — Scrivar is yours for life, with free updates included.
  • UNLIMITED eSIGN, BUILT IN — Send contracts and forms for signature and track every step. Recipients sign in their browser with no account or app needed. Replace DocuSign and save hundreds a year.
  • PC, MAC, AND WEB — Install on any Win 10/11 PC or macOS 11+ Mac (Intel or Apple Silicon), or work in your browser at scrivar.com. Same tools, same account, everywhere you work.
  • OCR + FULL OFFICE CONVERSION — Turn scanned documents into searchable, selectable text, and convert PDFs to and from Word, Excel, and PowerPoint with formatting kept intact.

For new work, evaluate a maintained HTML-to-PDF engine against your real documents. There is no evidence that one alternative is universally best. Before switching, compare:

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.
  • support for the CSS your templates use;
  • page breaks, widows and orphans, headers and footers;
  • font embedding, multilingual shaping and encoding;
  • reproducibility across deployment systems;
  • integration effort and the cost of validating existing PDFs.

Keep a representative regression set: short and long paragraphs, justified lists, tables, images, right-to-left or Thai text where applicable, and pages near a break. Render it with the old and candidate engines, then inspect both visual output and extracted text.

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

Or skip the browser setup

If your actual requirement is to obtain a clean image or PDF of a web page rather than preserve a wkhtmltopdf pipeline, ScreenshotNeo provides a website screenshot API and MCP server. It accepts a URL in one request and can return PNG, JPEG, WebP or PDF. Cookie and consent banners are accepted and removed before capture, along with more than 60 known consent platforms, newsletter popups and chat widgets; each cleanup step can be disabled.

Only clean shots are billed. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads and cache hits cost nothing, and the response identifies the result with X-Page-Verdict and X-Billed headers. An MCP server supplies take_screenshot, get_page_info and capture_pdf tools for Claude, Cursor and other MCP clients.

One-call example (see the ScreenshotNeo documentation for all options):

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

ScreenshotNeo also supports full-page capture with lazy images loaded, CSS-selector element capture, dark mode, 12 device presets and custom viewports, retina scale, PDF paper sizes and margins, HTML/CSS-to-image, custom CSS and JavaScript, clicks before capture, hidden selectors, selector or network-idle waits, request and resource blocking, custom headers, cookies, user agents and Authorization, timezone and geolocation, transparent backgrounds, resizing, TTL caching, signed image links, asynchronous jobs with signed webhooks, bulk capture of 100 URLs per call, a usage API and an OpenAPI specification. Parameter names used by other screenshot APIs also work.

Best Value
PDF Extra Premium - Professional PDF Editor - Edit, Protect, Annotate, Fill & Sign PDFs - 1 Year License - 1 PC | 50GB Cloud Storage
  • EDIT pages, text, images & designs in PDF documents.
  • FILL & Digitally Sign PDF Forms. 50 GB MobiDrive cloud storage included.
  • VIEW and Annotate PDFs – Intuitive viewing experience & document commenting and mark up.
  • PROTECT and Encrypt PDFs to restrict opening, editing or printing. Advanced Digital Certification included.
  • 1 Year License for 1 Windows PC or Laptop.

The Free plan includes 1,000 screenshots per 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.

Troubleshooting checklist

The PDF overlaps only on the server

  • Compare wkhtmltopdf --version, patched-Qt status, OS package and executable path.
  • Verify that the same fonts are installed and loaded.
  • Run the minimal file on both machines with identical options.

Removing a newline helps, but the template keeps reintroducing it

  • Inspect the rendered HTML after templating, not the source template.
  • Normalize accidental CRLFs between inline text nodes while preserving intentional whitespace.
  • Add a regression test containing the original paragraph.

Left alignment works but justification is required

  • Confirm the font and encoding first.
  • Test smart shrinking and fixed page-width settings as separate variables.
  • Compare another build or a maintained renderer before accepting a permanent visual compromise.

Only multilingual text fails

  • Check script coverage, fallback fonts and UTF-8 decoding.
  • Test a paragraph containing only the affected script.
  • Compare output with and without the custom font; do not infer causation from one report.

Changing smart shrinking changes pagination

That is expected: the option changes scaling behavior. Choose the setting that matches your required page dimensions, then validate every page break. Do not describe the setting as a justification fix unless your own controlled test demonstrates a document-specific improvement.

Security when rendering server-side

The wkhtmltopdf status guidance warns not to use it with untrusted HTML. Sanitize user-supplied HTML and JavaScript before passing it to the renderer; otherwise, the rendering process can enable a complete server takeover. Isolate the process, restrict network access and file permissions, and avoid allowing arbitrary local-file access where your deployment permits those controls.

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

Recommended order of operations

  1. Capture the exact version, build, OS, fonts and command line.
  2. Reduce the document to one paragraph and a fixed page width.
  3. Compare wkhtmltopdf with a current browser.
  4. Inspect CRLFs, repeated spaces, non-breaking spaces, tabs, Unicode whitespace and encoding.
  5. Test the intended font and a known fallback font.
  6. Switch temporarily to text-align: left to isolate justification.
  7. Compare default scaling with --disable-smart-shrinking while recording DPI and page settings.
  8. Test another build, then assess a maintained renderer against a regression corpus.

Frequently Asked Questions

Is `–disable-smart-shrinking` the official fix for justified text?

No. It changes WebKit’s shrinking and pixel/DPI behavior. It is a controlled diagnostic for scale and line-break differences, not a documented justification fix.

Should I remove all newlines from HTML paragraphs?

No. Remove or normalize only accidental line endings demonstrated to trigger your case; preserve meaningful whitespace and test the rendered output.

Do these reports prove wkhtmltopdf 0.12.6 is affected?

The cited user reports concern 0.12.5-era builds. They do not establish identical behavior in every 0.12.6 build or package.

Quick Recap

Bestseller No. 1
PDF Extra Lifetime - Professional PDF Editor - Best Adobe Acrobat Pro Alternative - Lifetime License for Windows PC
PDF Extra Lifetime - Professional PDF Editor - Best Adobe Acrobat Pro Alternative - Lifetime License for Windows PC
Perfect Adobe Acrobat Pro alternative – lifetime license for Windows 10 and 11.; EDIT text, images, pages, hyperlinks, designs in PDF documents. ORGANIZE PDFs.
$99.99
Bestseller No. 2
MixPad Free Multitrack Recording Studio and Music Mixing Software [Download]
MixPad Free Multitrack Recording Studio and Music Mixing Software [Download]
Create a mix using audio, music and voice tracks and recordings.; Customize your tracks with amazing effects and helpful editing tools.
SaleBestseller No. 3
Adobe Acrobat 6 PDF For Dummies
Adobe Acrobat 6 PDF For Dummies
Used Book in Good Condition
$13.00
Bestseller No. 5
PDF Extra Premium - Professional PDF Editor - Edit, Protect, Annotate, Fill & Sign PDFs - 1 Year License - 1 PC | 50GB Cloud Storage
PDF Extra Premium - Professional PDF Editor - Edit, Protect, Annotate, Fill & Sign PDFs - 1 Year License - 1 PC | 50GB Cloud Storage
EDIT pages, text, images & designs in PDF documents.; FILL & Digitally Sign PDF Forms. 50 GB MobiDrive cloud storage included.
$35.00

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.