October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PCOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
CSS

How to Show Table Borders in wkhtmltopdf PDFs (and Fix Borders That Vanish at Page Breaks)

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.

To show table borders in a PDF generated by wkhtmltopdf, set an explicit, visible border on the table cells and choose a border model deliberately. Start with this CSS:

table {
  border-collapse: collapse;
}
th,
td {
  border: 1px solid #333;
}

If the border appears on a short table but disappears, moves, or overlaps when the table crosses a page, the problem is probably pagination or surrounding layout as well as CSS. Test a one-page and a multi-page version, then inspect page-break rules, repeated headers, wrappers, and your wkhtmltopdf build.

Use explicit borders on the table and every cell

A browser can draw a table using inherited or user-agent styles, but a PDF conversion is more predictable when the table structure is styled explicitly. Give table, th, and td a border style, width, and color. A solid border with a nonzero width is the safest diagnostic baseline.

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  border: 1px solid #333;
  padding: 6px 8px;
  text-align: left;
}

border-collapse: collapse makes adjacent cell borders share one line instead of leaving a gap. Under the CSS 2.2 collapsed-border model, the effective border is resolved from the borders of the table and the cells that collapse with it; styling only the table is therefore not always enough. See the CSS 2.2 table specification for the model’s rules.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Canon Canoscan Lide 300 Scanner (PDF, AUTOSCAN, Copy, Send)
  • Scanner type: Document
  • Connectivity technology: USB
  • With Auto Scan Mode, the scanner automatically detects what you're scanning
  • Digitize documents and images

Complete minimal HTML example

<!doctype html>
<html>
<head>
  <meta charset="utf-8">
  <style>
    @page { margin: 18mm; }
    body { font-family: Arial, sans-serif; font-size: 11pt; }
    table { width: 100%; border-collapse: collapse; }
    th, td { border: 1px solid #333; padding: 6px 8px; }
    th { background: #eee; }
  </style>
</head>
<body>
  <table>
    <thead><tr><th>Item</th><th>Status</th></tr></thead>
    <tbody>
      <tr><td>Invoice</td><td>Paid</td></tr>
      <tr><td>Receipt</td><td>Pending</td></tr>
    </tbody>
  </table>
</body>
</html>

Convert it with a command such as:

wkhtmltopdf input.html output.pdf

Keep the CSS in the document or provide the stylesheet with the conversion command. First verify that the generated HTML contains the expected table, row, header, and cell elements; a missing element cannot produce a border.

Choose the border model intentionally

Collapsed borders

Use border-collapse: collapse when you want a single grid line between adjacent cells. It usually produces the most compact table and is a good first test for wkhtmltopdf.

Separated borders

Use border-collapse: separate when you need a gap between cells or different spacing behavior. In that mode, control the gap with border-spacing:

table {
  border-collapse: separate;
  border-spacing: 2px;
}
th, td {
  border: 1px solid #333;
}

Do not combine a separated-border design with assumptions from the collapsed model. Compare the PDF with the browser rendering before changing multiple variables.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
Sale
Brother DS-640 Compact Mobile Document Scanner, (Model: DS640)
  • 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)

Diagnose a border that fails only at a page break

A missing line on a table that fits on one page is a different problem from a line that vanishes when a row moves to the next page. Make the distinction with a controlled comparison:

  1. Generate a PDF containing a short table that fits on one page.
  2. Generate a second PDF from the same HTML and CSS with enough rows to cross a page boundary.
  3. Open both PDFs at high zoom and note whether the failure is a missing top line, a broken side border, a repeated-header overlap, or a row split.
  4. Temporarily remove page-break declarations and layout wrappers, then convert again.
  5. Record the wkhtmltopdf version, operating system, patched-Qt status, HTML, and CSS.

If only the long table fails, keep the explicit borders but investigate pagination rather than endlessly changing colors or widths.

Keep rows together where practical

You can ask the converter not to split a row internally:

tr {
  page-break-inside: avoid;
}

This is a pagination hint, not a guaranteed repair. A row taller than the printable page cannot be kept intact, and wkhtmltopdf’s handling can vary by document and build.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Plustek PS186 Desktop Document Scanner, with 50-Pages Auto Document Feeder (ADF). for Windows 7/8 / 10/11 (Intel/AMD only)
  • Up to 255 customize favorite scan file setting with "Single Touch" , Support Windows 7/8/10
  • Turn paper documents into searchable, editable files - save scans as searchable PDF files; OCR function included
  • Info Barcode function - automatic categorization of complicate documentation and data with 1D or 2D Barcode page.
  • Intelligent color and image adjustments — Auto Rotate, Crop, Deskew and blank page remove with Plustek Image Processing Technology
  • Easy send scanned files to FTP server or personal NAS (FTP) with PDFs , Jpeg , TIFF or Png format. User can download scanner driver from Plustek website

Repeat headers carefully

Use a semantic thead so a header can be repeated on subsequent pages:

thead {
  display: table-header-group;
}
tfoot {
  display: table-footer-group;
}

Repeated headers are useful, but reports have documented cases where header repetition, row movement, and borders interact badly. Issue #2486, “page-break-inside behavior”, describes side-border continuation and a repeated header when a row moved in wkhtmltopdf 0.12.2.4 with patched Qt on Windows 7 SP1. That is historical, version-specific evidence, not a universal rule.

Inspect wrappers and parent layout

Temporarily replace responsive table wrappers, flex containers, transforms, and overflow rules with a plain block containing the table. A report in issue #1524 associates wrappers, flex layout, and repeated table headers with overlap or pagination problems in particular documents. Treat those comments as troubleshooting leads: they do not prove that every flex or responsive wrapper is incompatible.

CSS and HTML checks before changing wkhtmltopdf options

  • Confirm that your selector is not overridden later by a more specific rule such as .report td { border: 0; }.
  • Check all three border components: border-style, border-width, and border-color. A color matching the page background can look like a missing border.
  • Remove border: none, outline: none, and print-only overrides while diagnosing.
  • Use a printable width. A table wider than the page can be clipped, making an outer border appear absent.
  • Ensure the stylesheet is actually loaded by wkhtmltopdf. Relative URLs, blocked local files, and unavailable assets can make the PDF differ from the browser.
  • Use real table markup. Do not emulate rows with unrelated div elements when you need table pagination and repeated headers.

Converter settings that can affect the comparison

The official wkhtmltopdf settings documentation lists controls for loading images, enabling JavaScript, printing backgrounds, and intelligent shrinking. These options can change the page being converted, but the documentation does not identify a dedicated “repair table borders” switch.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
Hczrc Portable Scanner, Photo Scanner for A4 Documents, Handheld Scanner for Business, Photo, Picture, Receipts, Books, JPG/PDF Format Selection, UP to 900 DPI, with 16G SD Car
  • Note: No software installation is required. You need 2 AA batteries ( not included) and a memory card ( included) to use it directly. Scan mode: Press and hold "Scan" for 2 seconds to turn on the device, and then press "Scan", the green light is on. The scanner moves to scan the file until the green light turns off automatically (or press the "Scan" key and the green light goes out). The number shown on the display increases by 1 to indicate that the scan is complete.
  • Portable Scanner scans images or pictures quickly: Store JPEG/PDF files within seconds, scan images or pictures quickly, plug and play, no need any software preinstalled. Compatible with Windows XP/7/Vista/Mac OS 10.4 or above version.
  • Lightweight and travel-friendly: Stored in Micro SD card directly, support read data on your computer or phone with USB connected. Powered by 2pcs AA batteries, Compact Design, it is convenient to carry outside.
  • 3 Image Resolution: 3 modes of resolution for your options: 300dpi/600dpi/900dpi, you can save it at the clearest way, picture and document are showed clear as it is. Freely choose your favorite resolution.File Format: JPEG/PDF format is all available, Great storage capacity as it supports 32G Micro SD card(Included 16GB Card),total meet your need for business trip or daily use.
  • Widely Used: It is applicable in bank, insurance business, real estate agency,home, office, library or outdoors. suitable for lawyer, businessmen, students, travelers and amateur archivists. Scan your important files and save them immediately, no struggling in finding a printing shop, keep it confidential.

For a fair diagnosis, hold settings constant and change one variable at a time. If the table relies on JavaScript to populate rows, wait for that content to exist before conversion. If the border color or header background depends on printed backgrounds, verify the relevant background-print setting, but do not treat it as a substitute for a border declaration.

Version and build details matter

wkhtmltopdf output is influenced by its rendering engine, operating system, and build options. When comparing your result with an issue report, capture:

  • Exact wkhtmltopdf version (for example, 0.12.2.4 in the report for #2486).
  • Whether the binary uses patched Qt.
  • Operating system and architecture.
  • The complete command-line options.
  • A reduced HTML file that still reproduces the border failure.

Issue #3808, “Top line of table disappears after page break”, opened February 6, 2018, reports a missing top line after a table page break despite a configuration using table borders, border-spacing, border-collapse: collapse, and page-break declarations. The repository is archived and read-only, and the report demonstrates a symptom in one input—not a guaranteed behavior for every installation.

A repeatable troubleshooting workflow

  1. Reduce the document. Keep one table, a few columns, and enough rows to cross exactly one page.
  2. Apply the baseline CSS. Use collapsed borders and explicit borders on th and td.
  3. Compare pagination. Convert the short and long versions with the same command.
  4. Remove hints temporarily. Test without page-break-inside, repeated-header rules, flex parents, responsive wrappers, and overflow declarations.
  5. Reintroduce one feature at a time. The first change that recreates the defect identifies the area to redesign.
  6. Check printable geometry. Reduce margins, font size, cell padding, or column widths if content is being clipped.
  7. Test the same reduced file on the target build. A workaround that succeeds on one binary may not transfer to another.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Common symptoms, causes, and fixes

Symptom Likely area What to try
No borders anywhere Missing or overridden CSS Set explicit solid borders on th and td; inspect loaded stylesheets and specificity.
Outer border missing but inner lines show Table border or clipping Set a border on table, check printable width, margins, and overflow.
Top line disappears after a page break Pagination artifact Compare one-page and multi-page versions; test page-break rules and a reduced table.
Header overlaps the next row Repeated header or wrapper layout Test semantic thead without flex/responsive wrappers; compare on your exact build.
Side border extends unexpectedly Row splitting behavior Try page-break-inside: avoid on rows, recognizing that it is only a hint.
Browser and PDF disagree Assets, JavaScript, or print settings Verify resource loading, JavaScript timing, background printing, and converter options.

Performance and reliability considerations

Large tables increase layout and pagination work. Keep the diagnostic file small, then test the full report after the CSS is stable. Avoid unnecessary nested wrappers and scripts that continually resize rows. If your report contains very tall rows, no page-break rule can guarantee an intact row; redesign the content or allow a controlled split.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
Sale
Epson Workforce ES-50 Compact & Lightweight Mobile Document Scanner
  • 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

For production pipelines, archive the converter version, command, HTML template, stylesheet, and a representative PDF. A visual regression check that compares a short table and a page-spanning table will catch border changes that a browser-only test misses.

Or skip the browser setup

If you only need a clean image or PDF of a web page rather than control over wkhtmltopdf’s HTML/CSS rendering, ScreenshotNeo provides a website screenshot API. One GET request can return PNG, JPEG, WebP, or PDF. Its capture flow accepts cookie and consent banners before removing more than 60 known consent platforms, newsletter popups, and chat widgets; bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, and the response identifies the result with X-Page-Verdict and X-Billed headers.

cURL:

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

Python:

import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
open("shot.webp", "wb").write(r.content)

Node.js:

const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);

See the ScreenshotNeo documentation for parameters. It also offers an MCP server with take_screenshot, get_page_info, and capture_pdf tools for Claude, Cursor, and other MCP clients. Every plan includes its features; 1,000 screenshots per month are free with no card, and paid plans start at $5 for 3,000 shots. Create a free ScreenshotNeo account.

Frequently Asked Questions

Why do borders look lighter in the PDF than in the browser?

PDF viewers apply antialiasing at some zoom levels. Check the file at 100% and 200% zoom and use a darker, one-pixel border while diagnosing.

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.

Can a CSS rule guarantee that every row stays on one PDF page?

No. page-break-inside: avoid is a pagination hint; rows taller than the printable page or affected by renderer limitations can still split.

Should I switch to a different PDF engine immediately?

First reduce the HTML and identify whether the defect is CSS, pagination, or a build-specific artifact. Then compare engines only if the required layout cannot be made reliable on your supported wkhtmltopdf version.

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
Outdated Drivers Are Slowing You DownFree scan - exact matches
Windows Errors? Fix Them Before They SpreadFree repair 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.