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

Use --page-size to choose a standard paper format, or set both --page-width and --page-height for custom dimensions. Set each edge independently with --margin-top, --margin-bottom, --margin-left, and --margin-right. Include units such as mm, cm, or in.

Set a named page size and four margins

For a standard sheet, pass the page size and margin options before the input file or URL. This example creates a Letter-sized portrait PDF with 15 mm top and bottom margins and 12 mm side margins:

wkhtmltopdf 
  --page-size Letter 
  --orientation Portrait 
  --margin-top 15mm 
  --margin-bottom 15mm 
  --margin-left 12mm 
  --margin-right 12mm 
  input.html output.pdf

Replace input.html with a local HTML filename or a URL, and change output.pdf to the desired output path. The option names and units follow the wkhtmltopdf usage manual.

What the defaults mean

The usage manual for wkhtmltopdf 0.12.6 documents A4 as the default page size and Portrait as the default orientation. It documents a 10 mm default for the left and right margins; the cited manual excerpt does not specify top and bottom defaults, so set those explicitly when they matter.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Brother DCP-L2640DW Wireless Compact Monochrome Multi-Function Printer, Copy, Scan, Duplex, Mobile Printing
  • BEST FOR SMALL BUSINESSES – Engineered for extraordinary productivity, the Brother DCP-L2640DW Monochrome (Black & White) 3-in-1 combines laser printer, scanner, copier in one compact footprint and delivers high-quality black & white prints
  • FAST PRINTER WITH EFFICIENT SCANNING – Produces documents quickly with print speeds up to 36 ppm(2) and scan speeds up to 23.6/7.9 ipm(3) (black/color). A 50-page auto document feeder(4) allows for convenient, time saving multi-page scanning and copying
  • FLEXIBLE CONNECTION OPTIONS – Easily navigate the changing demands of your business with secure multi-device connectivity via built-in dual-band wireless (2.4GHz / 5GHz) and Ethernet. Or connect locally to a single computer via USB interface
  • BROTHER MOBILE CONNECT APP – Print, scan, and manage your wireless printer anytime, from almost anywhere from your mobile device. Order Brother Genuine Supplies, track toner usage, and complete more work on-the-go(5)
  • CHOOSE BROTHER GENUINE TONER – When it’s time to replace your toner, be sure to choose Brother Genuine TN830 or TN830XL replacement toner. And with Refresh EZ Print Subscription Service, you’ll never worry about running out of toner again and you’ll enjoy savings of up to 50%(6) on Brother Genuine Toner. Get started with Refresh today with a Free Trial(1)

Choose standard paper or custom dimensions

Use a named paper size

Choose --page-size for a recognized format such as A4, A3, Letter, or Legal. The official usage documentation says the default is A4 and that this option can change it to other formats. The available names can depend on the installed build; if you use an uncommon size, check that build’s help output and accepted values.

wkhtmltopdf --page-size A4 input.html output.pdf

Set a custom width and height

When a named format is not suitable, supply both dimensions with units. For example, these values specify a 210 mm by 297 mm page:

Rank #2
Brother HL-L2405W Wireless Compact Monochrome Laser Printer with Mobile Printing, Black & White Output | Includes Refresh Subscription Trial(1), Works with Alexa
  • BEST FOR HOMES & HOME OFFICES – Engineered for consistent, premium print quality, the Brother HL-L2405W Monochrome (Black & White) Laser Printer delivers sharp, crisp prints at an affordable price. Prints one-sided documents at speeds up to 30ppm(2)
  • COMPACT, CONNECTED PRINTER – Flexible connection options make this an ideal printer for home use and at-home offices. Securely connect to multiple devices with built-in dual-band wireless (2.4GHz/5GHz) or locally to a single computer via USB interface
  • BROTHER MOBILE CONNECT APP – Manage your printer remotely and print from your mobile device anytime, from almost anywhere. Order Brother Genuine Supplies, track toner usage, and complete more work on-the-go(3)
  • VERSATILE PAPER HANDLING – Enjoy seamless, reliable everyday printing with the 250-sheet paper tray(4) and a manual feed slot that enables printing on envelopes and specialty pape
  • BROTHER IS AT YOUR SIDE – Backed by Brother with a 1-year limited warranty and free online, call, or live chat support for the life of your printer
wkhtmltopdf 
  --page-width 210mm 
  --page-height 297mm 
  input.html output.pdf

The manual describes width and height as the finer-grained controls. Use them for a fixed custom canvas or unusual forms; the dimensions alone do not set margins.

Set orientation separately

Choose --orientation Landscape or --orientation Portrait. Portrait is the documented default. Orientation and the four margin flags are separate settings:

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.
Rank #3
Canon imageCLASS LBP6030w - Monochrome Single-Function Wireless Compact Wireless Laser Printer, 1 Year Limited Warranty, 19 PPM, White - Print Only
  • FAST PRINT SPEEDS: Print up to 19 pages per minute.
  • COMPACT DESIGN: Space-saving, compact design fits anywhere in your home, school or small office.
  • WIRELESS CONNECTIVITY: Print from almost anywhere in your workspace using your compatible mobile device.
  • PAPER CAPACITY: Up to 150 sheets.
  • SUSTAINABILITY: Uses less than 2 watts in Energy Saver mode.
wkhtmltopdf 
  --page-size A4 
  --orientation Landscape 
  --margin-top 12mm 
  --margin-bottom 12mm 
  --margin-left 15mm 
  --margin-right 15mm 
  input.html output.pdf

Adjust margins independently

Each margin option controls one edge. Values take a unit-bearing form, so prefer explicit values such as 15mm rather than relying on implicit units.

Option Controls Example
--margin-top Top whitespace 15mm
--margin-bottom Bottom whitespace 15mm
--margin-left Left whitespace 12mm
--margin-right Right whitespace 12mm

The libwkhtmltox settings reference gives unit-bearing examples including 2cm for a margin and 4cm or 12in for dimensions.

Rank #4
Brother HL-L2460DW Wireless Compact Monochrome Laser Printer with Duplex, Mobile Printing, Black & White Output | Includes Refresh Subscription Trial(1), Works with Alexa
  • BEST FOR HOME OFFICES & SMALL TEAMS – Engineered for consistent, premium print quality, the Brother HL-L2460DW Monochrome (Black & White) Laser Printer produces documents that are clear, crisp, and easy to review and share, all at an affordable price
  • COMPACT, CONNECTED, EXCEPTIONALLY EFFICIENT– Connect with built-in dual-band wireless (2.4GHz/5GHz), Ethernet, or to a single computer via USB interface. Prints at speeds up to 36ppm(2), plus automatic duplex printing saves time and reduces paper waste
  • BROTHER MOBILE CONNECT APP – Manage your wireless printer remotely and print from your mobile device anytime, from almost anywhere. Order Brother Genuine Supplies, track toner usage, and complete more work on-the-go(3)
  • VERSATILE PAPER HANDLING – Tackle high-volume black & white printing with the 250-sheet capacity paper tray.(4) The manual feed slot enables printing on envelopes and specialty paper
  • BROTHER IS AT YOUR SIDE – Backed by Brother with a 1-year limited warranty and free online, call, or live chat support for the life of your printer

Put options in the correct place

For one input, put global page geometry options before the input filename or URL, as in the examples above. The usage manual allows commands to contain page objects, covers, and a table of contents, and notes that options may be global or per object. Global Options must appear in the global options area. In a multi-object command, consult the manual’s option classification and scope rather than assuming a setting applies to every object.

Set the equivalent values through libwkhtmltox

For the library interface, use the PDF global settings below rather than CLI flag names. The settings reference specifies UTF-8 string values:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
HP LaserJet M110w | Monochrome | Laser Printer
  • FROM AMERICA'S MOST TRUSTED PRINTER BRAND – Perfect for small teams printing professional-quality black & white documents and reports. Perfect for 1-3 people
  • WORLD'S SMALLEST LASER IN ITS CLASS – Precision laser printing that fits anywhere
  • FAST PRINT SPEEDS – Up to 21 black-and-white pages per minute single-sided
  • WIRELESS WITH SELF-RESET – Helps you stay connected
  • PRINT FROM ANY DEVICE – Wireless printing from any mobile device, PC or tablet. Works with Microsoft, Mac, AirPrint, Android, Chromebook and more
CLI option libwkhtmltox global setting Example value
--page-size size.pageSize A4
--page-width size.width 210mm
--page-height size.height 297mm
--orientation orientation Landscape or Portrait
--margin-top margin.top 15mm
--margin-bottom margin.bottom 15mm
--margin-left margin.left 12mm
--margin-right margin.right 12mm

See the libwkhtmltox: Setting reference for the library’s settings format and additional context.

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

Troubleshoot page size and margin problems

The output uses an unexpected paper size

  • Check that --page-size is spelled correctly and uses a format recognized by the installed build.
  • If you need exact dimensions, provide both --page-width and --page-height, each with a unit.
  • Check the installed version and its help output. The cited command-line manual identifies itself as wkhtmltopdf 0.12.6 with patched Qt; a different build may not expose precisely the same accepted formats.

The whitespace is wrong on one edge

  • Confirm that the value is attached to the correct edge-specific option. Top and bottom are not interchangeable with left and right.
  • Set all four margins explicitly if you need predictable geometry, particularly because the cited manual excerpt only states the default for left and right.
  • Include a unit with each value, such as 8mm or 0.5in.

Settings appear not to apply to every item

In a command with multiple objects, verify whether each option is global or object-specific and place it in the scope prescribed by the usage manual. For a single input, keep global geometry options before the input.

Check a deployment before depending on a format

The CLI manual labels itself version 0.12.6 with patched Qt, but the exact behavior of a particular installed binary is not established by that manual alone. Check wkhtmltopdf --version and the local help output when accepted formats or deployment behavior are important.

Or skip the browser setup

If your task is to capture a live website as an image or PDF rather than control a wkhtmltopdf conversion, ScreenshotNeo offers a one-request screenshot API. This cURL example saves a WebP capture of Stripe; consult the ScreenshotNeo docs for request options and PDF settings:

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 removes cookie banners, newsletter popups, and chat widgets before capture; those cleanup 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. Its MCP server lets AI agents use screenshot tools. The free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000.

Sign up for ScreenshotNeo’s free plan.

Source and version note

The command-line details here follow the wkhtmltopdf usage manual, which identifies its documentation as version 0.12.6 with patched Qt and gives no publication year. Library setting names are from the libwkhtmltox reference. Confirm local help and version output when reproducing behavior on a specific installation.

Quick Recap

Bestseller No. 3
Canon imageCLASS LBP6030w - Monochrome Single-Function Wireless Compact Wireless Laser Printer, 1 Year Limited Warranty, 19 PPM, White - Print Only
Canon imageCLASS LBP6030w - Monochrome Single-Function Wireless Compact Wireless Laser Printer, 1 Year Limited Warranty, 19 PPM, White - Print Only
FAST PRINT SPEEDS: Print up to 19 pages per minute.; PAPER CAPACITY: Up to 150 sheets.; SUSTAINABILITY: Uses less than 2 watts in Energy Saver mode.
$140.00
Bestseller No. 5
HP LaserJet M110w | Monochrome | Laser Printer
HP LaserJet M110w | Monochrome | Laser Printer
WORLD'S SMALLEST LASER IN ITS CLASS – Precision laser printing that fits anywhere; FAST PRINT SPEEDS – Up to 21 black-and-white pages per minute single-sided

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.