The Tool Desk
Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →For a fixed custom output height, use --page-height with an explicit unit, for example wkhtmltopdf --page-height 100mm input.html output.pdf. Set the corresponding width with --page-width. This controls the PDF page box; it does not, according to the documented options, measure each page’s rendered content and automatically choose a different height for every page.
That distinction matters for receipts, labels and “one input item per page” documents. A fixed height is straightforward. Content-dependent height requires a separate measurement-and-render workflow, and its behavior must be verified with the exact wkhtmltopdf binary and wrapper your application uses.
What “variable page height” means in wkhtmltopdf
There are two different requirements commonly described as variable height:
- One custom height for the whole output: every page uses the same nonstandard height, such as 100 mm.
- A content-sized height: each page becomes exactly as tall as its own HTML content, with no unused space and no unexpected page break.
--page-height solves the first requirement. The reviewed command-line and library references document page dimensions, named paper sizes and shrinking behavior, but do not document automatic per-page content-height detection. Do not assume that a custom height is an auto-sizing mode.
Free tools Windows power users keep installed
One-click scans. No signup required.
#1 Best Overall
Set a fixed custom height from the command line
Basic command
wkhtmltopdf --page-height 100mm input.html output.pdf
Replace 100mm with the height required by your paper, label or receipt. The value is a unit-bearing dimension; using the unit explicitly avoids ambiguity.
Set width and height together
wkhtmltopdf
--page-width 80mm
--page-height 200mm
input.html output.pdf
Width and height are independent controls. For a narrow receipt, for example, define both dimensions instead of relying on a named office-paper size.
Use a named paper size when a standard is sufficient
wkhtmltopdf --page-size A4 input.html output.pdf
wkhtmltopdf --page-size Letter input.html output.pdf
The project usage documentation identifies A4 as the default paper size and allows named sizes such as A4 or Letter through --page-size. Choose a named size when interoperability matters; choose explicit width and height when the physical output is custom.
Units, defaults and build differences
Prefer explicit units
The Debian Bookworm manual describes the default unit for --page-height as millimeters. Other packaging or customized builds can differ in option parsing, so write 100mm, 4in or 10cm rather than an unqualified number. Confirm the syntax accepted by the executable installed in production.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Check the executable you are actually calling
wkhtmltopdf --version
wkhtmltopdf --help | grep -E 'page-(size|width|height)'
Wrappers can expose settings under different names, and distribution packages may not behave identically. Record the binary version, operating system package and wrapper version with your deployment so a rendering change can be traced to a real environment difference.
Can wkhtmltopdf automatically size every page to its content?
Not from the documented --page-height control. That option defines an output dimension; it is not described as a measurement pass that calculates a new height for every rendered page. If you need a receipt whose height depends on line count, treat it as an application workflow:
- Render or measure representative HTML using the same fonts, assets, viewport and binary used for the final job.
- Calculate the required physical height, including margins and any fixed header or footer space.
- Invoke wkhtmltopdf with that calculated value in
--page-height. - Inspect the resulting PDF for overflow, clipping and an unwanted second page.
This is not a universal built-in algorithm. Test short, typical and unusually long content with your exact wrapper. A customized build may add behavior that is absent from the standard option reference, while a wrapper may translate or override settings.
One page per item
For invoices, labels or tickets, a reliable pattern is one conversion job per item, each with its own calculated height. If you combine several items in one HTML document, a single page-height setting applies to the output job; it is not documented as a per-item height map.
Recommended Free Tools
Library and wrapper settings
The library settings reference exposes the same dimensions through size.height and size.width. It also exposes size.pageSize for named paper sizes. Dimensions are represented as strings with units, such as 12in or 4cm.
Mapping command-line options to library settings
| Requirement | Command line | Library setting |
|---|---|---|
| Named paper | --page-size A4 |
size.pageSize |
| Custom width | --page-width 80mm |
size.width = "80mm" |
| Custom height | --page-height 200mm |
size.height = "200mm" |
Set either the named size or explicit dimensions according to your wrapper’s precedence rules. If both are accepted, verify which one wins rather than assuming the last assignment is used. The references establish the available fields, not the configuration behavior of every third-party binding.
Python subprocess example
from pathlib import Path
import subprocess
html = Path("receipt.html")
pdf = Path("receipt.pdf")
subprocess.run([
"wkhtmltopdf",
"--page-width", "80mm",
"--page-height", "200mm",
str(html),
str(pdf),
], check=True)
print(f"Wrote {pdf}")
This example delegates option parsing to the installed executable. For a content-dependent height, calculate the string passed to --page-height before constructing the argument list, then run the same validation against the output PDF.
Page size versus shrinking: two separate controls
Smart shrinking is a layout scaling or fitting feature, not a documented automatic page-height mechanism. The command-line description frames it as changing the pixel-to-DPI relationship; the library reference describes intelligent shrinking as fitting more content on a page.
When shrinking is enabled
- Content may be scaled to fit the available page geometry.
- Text and spacing can appear smaller than the CSS design suggests.
- A page that previously overflowed may fit, but its physical scale has changed.
When shrinking is disabled
- CSS dimensions are easier to reason about at the chosen page size.
- Content that exceeds the page can overflow or create additional pages instead of being scaled down.
- You must handle width, margins and long content explicitly.
Evaluate shrinking separately from --page-height. Changing the height changes the page box; changing shrinking changes how content is fitted into that box. Keep the setting consistent when comparing output dimensions during troubleshooting.
A repeatable workflow for receipts and labels
- Define the physical geometry. Write down width, minimum height, margins and whether the output is portrait or landscape.
- Choose units. Use explicit millimeters, inches or centimeters in every command or library field.
- Start with a fixed height. Generate a short and a long fixture with
--page-widthand--page-height. - Check pagination. Look for a blank trailing page, clipped footer, unexpected break or scaled-down text.
- Decide whether content sizing is truly required. If a fixed maximum height is acceptable, keep the simpler configuration. If not, add an application-level measurement step.
- Validate production assets. Fonts, images, JavaScript timing and network access can change the rendered height, so test with the same runtime conditions used in production.
Common problems and fixes
“Unknown long argument” or the option is ignored
Your wrapper may not pass the option through, or the executable may be an older or customized build. Run wkhtmltopdf --help, verify the binary path, and inspect the wrapper’s documented page-size fields. Do not silently fall back to a named paper size if the physical dimensions matter.
The PDF still looks like A4
Check that the command targets the intended executable and that no later wrapper setting replaces size.width or size.height. Also check whether a named --page-size setting is being applied after custom dimensions.
Content is clipped at the bottom
The chosen height is smaller than the rendered content, or margins and footer space were not included in the calculation. Increase the fixed height, reduce content, or calculate a larger value for that item. Do not expect smart shrinking to change the page dimension.
Outdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchPC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11A second page appears for a receipt
Overflow has exceeded the fixed page box. Test with the exact HTML and assets, inspect margins and fixed-position elements, and either increase the calculated height or redesign the content. If your requirement is one page per item, convert items separately so each job can receive its own height.
The result changes when content gets longer
That is expected when the height is fixed and pagination is allowed. A fixed page dimension does not promise one-page output. Use representative long fixtures and make the application’s height calculation conservative enough to include wrapping, fonts and footer content.
Units behave unexpectedly
Use a unit suffix on every dimension and test the installed build. The Debian Bookworm manual describes millimeters as the default for page height, but relying on an implicit default makes a migration harder to diagnose.
Performance, reliability and cost considerations
There is no documented universal content-height algorithm to optimize or rely on. A measurement-and-render design usually performs more work than one fixed conversion, so cache stable templates and avoid recalculating dimensions when the input and rendering environment have not changed. Keep timeouts and failure handling around the conversion process, and retain the generated PDF plus the command or settings that produced it for debugging.
Quick wins for a faster PC:
Clear out junk files and repair common Windows errorsFree Scan →Scan for outdated or missing drivers - takes under a minuteDriver Scan →Repair Windows errors before they cause bigger problemsFix Now →For high-volume jobs, separate conversion failures from valid PDFs with an explicit process exit check. Test both extremes: minimal content can expose unwanted blank space, while long content exposes overflow and page-break behavior. Any timing or capacity figure is environment-specific; measure it on your own binary, host and HTML.
Rank #4
Or skip the browser setup
If your actual goal is to capture a web page as an image or PDF rather than control a local wkhtmltopdf conversion, ScreenshotNeo provides a single HTTP request. It accepts cookie and consent banners as a visitor and removes more than 60 known consent platforms, newsletter popups and chat widgets before capture; each cleanup step can be disabled. Bot checks or CAPTCHAs, 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. It also offers an MCP server for Claude, Cursor and other MCP clients, with take_screenshot, get_page_info and capture_pdf tools.
Use the ScreenshotNeo API documentation for authentication and options. The basic call is:
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}`);
ScreenshotNeo includes full-page capture, CSS-selector element capture, device presets, custom viewports, retina scale, PDF paper and margin controls, JavaScript and CSS injection, waits, request blocking, cookies, headers, geolocation, caching, signed links, asynchronous jobs, bulk capture and a usage API. Every feature is on every plan. The Free plan includes 1,000 shots per month with no card; paid plans start at $5 for 3,000 shots. Create a free ScreenshotNeo account to try it without a card.
Choosing the right approach
| Need | Best starting point | Important qualification |
|---|---|---|
| Same custom height for every page | --page-height and optionally --page-width |
Use explicit units and test the installed build. |
| Standard office paper | --page-size A4 or another named size |
A4 is the documented default when no custom size is selected. |
| Each receipt sized to its own content | Application-level measurement followed by a conversion | Per-page automatic sizing is not documented by the reviewed controls. |
| Remote page screenshot or PDF without browser setup | ScreenshotNeo | It is a hosted capture API, not a replacement for a local wkhtmltopdf binary. |
Frequently Asked Questions
Can I assign a different height to page two with one wkhtmltopdf command?
The documented size settings describe one output geometry, not a per-page height list. Generate separate conversion jobs or verify a wrapper-specific extension with a small test document.
Should I use millimeters or inches?
Use the unit that matches your physical specification, but include the suffix every time. Explicit units are clearer than relying on a build’s default.
Does disabling smart shrinking make the PDF content-sized?
No. Shrinking changes fitting or scale; it does not provide documented automatic height measurement.
How can I prove that a calculated receipt height is sufficient?
Run short, typical and worst-case fixtures through the same binary, fonts, assets and wrapper used in production, then inspect the PDF dimensions and page breaks.
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.

