Driver FixRecommendedSound, Wi-Fi or graphics acting up? Check drivers firstFind missing or outdated drivers fast.Check DriversOctober 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 PC×
Skip to content
World desk3 min

How to Set Page Size and Margins in wkhtmltopdf

Use wkhtmltopdf’s paper-size or custom-dimension options and set each margin separately with unit-bearing values.
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 a custom page. Set each edge independently with --margin-top, --margin-bottom, --margin-left, and --margin-right. Include units such as mm, cm, or in in dimension and margin values.

Set page size and margins from the command line

For a standard sheet, pass a named format to --page-size. This example uses Letter paper, portrait orientation, and explicit margins:

As an Amazon Associate I earn from qualifying purchases.

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 an HTML file or URL and output.pdf with the destination filename. The options are placed before the input so they act as global settings for this single-input command.

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

Choose standard or custom page dimensions

Named paper size

The wkhtmltopdf usage manual for version 0.12.6 documents A4 as the default page size. Specify another named format with --page-size; its examples include A3, Letter, and Legal. The full set depends on the paper-size values supported by the installed build, so check that build for uncommon formats. See the wkhtmltopdf usage manual.

#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)

Custom width and height

When a named format does not match the page you need, set both dimensions. For example, --page-width 210mm --page-height 297mm specifies a 210-by-297 mm page. This is an example of option syntax, not a claim about a conversion tested here. The manual identifies width and height as the finer-grained controls.

Orientation

Use --orientation Landscape or --orientation Portrait. Portrait is the documented default. Orientation controls page direction; it does not replace setting the four margins.

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

Set each margin independently

Use the corresponding option for each edge: --margin-top, --margin-bottom, --margin-left, and --margin-right. Supply a value with a unit, such as 15mm or 2cm. The usage manual documents a 10 mm default for left and right margins; its cited excerpt does not state defaults for top and bottom, so set all four explicitly when predictable whitespace matters.

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

Place options correctly in multi-object commands

wkhtmltopdf can combine page objects, covers, and a table of contents in output order. The manual distinguishes global options from per-object options, and states that options in the Global Options section must be placed in the global options area. For commands with multiple objects, consult the option classification and scope in the usage manual rather than assuming one geometry setting applies to every object.

Rank #3
Sale
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.

Set the same values through libwkhtmltox

The library’s PDF global settings expose the equivalent controls as string-valued settings:

CLI option libwkhtmltox setting Example value
--page-size size.pageSize A4
--page-width size.width 210mm
--page-height size.height 297mm
--orientation orientation Landscape
--margin-top margin.top 2cm
--margin-bottom margin.bottom 2cm
--margin-left margin.left 2cm
--margin-right margin.right 2cm

The libwkhtmltox settings reference shows unit-bearing values, including centimetres for margins and centimetres or inches 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

Check the installed build when output differs

  • Run wkhtmltopdf --version and inspect the local help output to confirm the binary version and accepted options.
  • If a less common named paper format is rejected or behaves unexpectedly, verify its availability in that installed build rather than assuming every package supports the same set.
  • If a margin or page dimension is not applied as expected in a command containing several objects, check whether the setting is global or per-object and move it to the appropriate options area.

The project usage manual labels itself as wkhtmltopdf 0.12.6 with patched Qt. The documented syntax is useful for configuring that command-line interface, but it does not establish the behavior of every locally packaged binary.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
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 you need a screenshot or PDF from a URL rather than a wkhtmltopdf conversion, ScreenshotNeo offers a one-request API and an MCP server for AI agents. For a PDF, use the capture_pdf MCP tool or the API’s documented PDF options; the call below requests a WebP screenshot:

Best Value
HP LaserJet M110w | Monochrome | Laser Printer | Fast Black-and-White Printing | Mobile Printing | Wireless Printing | Fast Printing
  • 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
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 PDF and page-layout parameters. Before capture, it accepts cookie or consent banners and removes more than 60 known consent platforms, newsletter popups, and chat widgets; each of those steps can be turned off. Bot checks, blank pages, failed loads, timeouts, and cache hits are not billed, and response headers identify the page verdict and billing status. Its MCP server includes take_screenshot, get_page_info, and capture_pdf. The Free plan includes 1,000 screenshots per month with no card required; paid plans start at $5 for 3,000 shots.

Sign up for ScreenshotNeo and get 1,000 free screenshots a month with no card.

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

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.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Outdated Drivers Are Slowing You DownFree scan - exact matches

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.