October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
PDF

How to Fix Incorrect PDF Page Sizes in wkhtmltopdf

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

If a PDF created with wkhtmltopdf has the wrong sheet dimensions, set the paper explicitly: use --page-size for a supported standard size such as A4 or Letter, or set both --page-width and --page-height for custom dimensions. Then check orientation and margins. If the sheet measures correctly but the content looks too small, narrow, or shifted, investigate layout and scaling separately rather than changing the paper size again.

First determine whether the sheet or the content is wrong

A PDF page has physical dimensions, while the HTML rendered on it has its own layout. Those can fail independently. A page can have the intended A4 dimensions while its content is scaled down, leaves unexpected whitespace, or appears shifted. Conversely, content may look plausible in a viewer while the PDF page box is actually Letter or another size.

Before adjusting CSS or scaling, measure the generated PDF page dimensions using the document-properties view in a PDF reader or a PDF inspection utility. Compare that result with the actual intended paper size. This measurement is a diagnostic step; the wkhtmltopdf documentation does not prescribe a particular inspection tool.

  • Wrong page dimensions: correct the paper setting with a named size or explicit width and height.
  • Correct dimensions, wrong content fit: inspect orientation, margins, viewport-related layout, and smart shrinking.
  • Unclear expected dimensions: decide whether the output should be A4, Letter, Legal, or a specific custom width and height. Do not assume the HTML page’s CSS dimensions define the PDF sheet.

wkhtmltopdf’s usage documentation says the default rendered page size is A4. It also documents selecting a named size with --page-size and finer control through width and height options. See the wkhtmltopdf usage documentation.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
PDF Extra 2024| Complete PDF Reader and Editor | Create, Edit, Convert, Combine, Comment, Fill & Sign PDFs | Lifetime License | 1 Windows PC | 1 User [PC Online code]
  • EDIT text, images & designs in PDF documents. ORGANIZE PDFs. Convert PDFs to Word, Excel & ePub.
  • READ and Comment PDFs – Intuitive reading modes & document commenting and mark up.
  • CREATE, COMBINE, SCAN and COMPRESS PDFs
  • FILL forms & Digitally Sign PDFs. PROTECT and Encrypt PDFs
  • LIFETIME License for 1 Windows PC or Laptop. 5GB MobiDrive Cloud Storage Included.

Set a standard paper size explicitly

For standard paper, use a documented named size rather than relying on a default that may be easy to overlook in a wrapper or application configuration. For example:

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

Replace A4 with the supported paper name appropriate to the document, such as Letter or Legal. The documentation describes those examples. The command also sets portrait orientation; omit or change that option if the intended output is landscape.

This is a configuration example, not a guarantee that every build, input file, or environment will render identically. Confirm the resulting PDF’s page dimensions on the executable you actually use.

Rank #2
MobiPDF Lifetime - Professional PDF Editor for Windows | Edit, Sign & Convert PDFs | Best Adobe Acrobat Pro Alternative | Lifetime License
  • Edit PDFs with Ease. Modify text, images, and layouts directly within your PDF documents.
  • Convert & Organize. Export PDFs to Word, Excel, or ePub, and organize files with ease.
  • Read & Annotate. Enjoy intuitive reading modes and powerful tools to comment, highlight, and mark up PDFs.
  • Create & Manage PDFs. Create new PDFs, combine multiple files, scan documents, and compress for easy sharing.
  • Fill & Sign Forms. Complete forms and digitally sign documents with secure e-signature tools.

Set a custom width and height

When the required sheet does not match a standard named size, set both dimensions explicitly. For example, the following width and height are A4 dimensions expressed in millimetres, but the same approach can be adapted to a genuinely custom format:

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.
wkhtmltopdf --page-width 210mm --page-height 297mm input.html output.pdf

The wkhtmltopdf usage documentation identifies --page-width and --page-height as the finer-control options. Check wkhtmltopdf --help on the installed executable for accepted units and syntax, particularly when using an older or packaged build. Setting both dimensions makes the intended geometry explicit; changing only one can leave the other dimension controlled by a default or other setting.

Do not rely on --page-size custom without checking your build

Do not assume the word custom is a portable named size. An issue report for wkhtmltopdf 0.12.1 with patched Qt records --page-size custom being rejected as an invalid argument. That report is specific to the described environment and does not prove that every release rejects it. For custom dimensions, the documented width-and-height controls are the clearer route; validate them locally. See issue #2023.

Rank #3
Adobe Acrobat Pro | PDF Software | Convert, Edit, E-Sign, Protect | PC/Mac Online Code | Activation Required
  • Create and edit PDFs. Collaborate with ease. E-sign documents and collect signatures. Get everything done in one app, wherever you go.
  • Edit text and images without jumping to another app.
  • E-sign documents or request e-signatures on any device. Recipients don’t need to log in to e-sign.
  • Convert PDFs to editable Microsoft Word, Excel, or PowerPoint documents.
  • Share PDFs for collaboration. Commenting features make it easy for reviewers to comment, mark up, and annotate.

Check orientation and margins before changing CSS

Orientation and the four margins affect the usable area inside a sheet. The paper can be exactly the requested size while a large margin leaves less room for content, making it seem too small or causing wrapping and apparent misalignment. Set the intended portrait or landscape orientation, then inspect top, bottom, left, and right margins in the command or in the application settings that invoke wkhtmltopdf.

Page geometry is not the only rendering control. The usage documentation lists --viewport-size and smart-shrinking controls separately from page-size controls. A viewport can affect layout in certain cases, and smart shrinking is a WebKit layout behavior; neither should be treated as a substitute for choosing the PDF sheet dimensions. First establish that the measured page size is correct, then change viewport or shrinking behavior only if the content layout is still wrong. The usage documentation describes page size, orientation, margins, viewport, and smart shrinking as distinct controls.

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

Use the equivalent settings in libwkhtmltox

If an application uses the library interface rather than invoking the command-line program, configure the corresponding page-size settings on the object used to generate the PDF. The libwkhtmltox settings reference exposes size.pageSize, size.width, and size.height; its width and height examples use explicit units. The relevant setting names are documented in the libwkhtmltox page settings reference.

Rank #4
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

Choose between CLI and library configuration based on how your application integrates wkhtmltopdf. The CLI exposes named size and explicit dimension options; the library provides corresponding settings for applications that call the library. The available documentation does not establish a full cross-version compatibility matrix, so verify the settings against the version actually deployed rather than assuming all builds behave alike.

Diagnose the result in a controlled sequence

  1. Write down the target dimensions. Choose a standard format such as A4, Letter, or Legal, or record the exact custom width and height and units. Establish this independently of the page’s CSS.
  2. Record the executable and version. Run wkhtmltopdf --version and keep the output with the issue details. Version matters when comparing behavior or reporting a failure.
  3. Set the sheet explicitly. Use --page-size for a supported named format or both --page-width and --page-height for custom geometry. If using the library, set the corresponding size fields.
  4. Set orientation and inspect all margins. Confirm portrait or landscape and check top, bottom, left, and right values. Do not use margins to compensate for the wrong physical sheet size.
  5. Generate and measure the PDF. Compare the output page dimensions with the target before touching CSS, viewport, or shrinking options.
  6. Isolate layout behavior. If the dimensions match but content fit does not, test the viewport and smart-shrinking behavior separately. Change one relevant setting at a time so the source of the difference remains apparent.
  7. Reduce the case if the problem persists. Save the exact invocation or library settings and create a minimal HTML, CSS, and JavaScript example that still reproduces the issue.

The project’s support guidance asks for version information and a detailed reproducible case when reporting issues. Include the command or settings and the smallest page that demonstrates the problem; see wkhtmltopdf support guidance.

Common failure modes and fixes

Symptom Likely distinction to check Useful next step
The PDF has the wrong physical page dimensions The page-size setting may be implicit, misconfigured, or not applied by the invoking wrapper. Set a supported named size or explicit width and height, regenerate, and measure the result.
--page-size custom is rejected A specific issue report records rejection on wkhtmltopdf 0.12.1 with patched Qt; behavior is not established for every build. Use the documented explicit dimension options and check the installed executable’s help.
The sheet measures correctly but content looks too small Margins reduce available space; viewport or smart shrinking may affect layout and fit. Verify margins and orientation, then isolate viewport and shrinking behavior without changing sheet dimensions.
Content wraps, shifts, or leaves unexpected whitespace The physical sheet may be correct while usable-area geometry or rendering layout differs from expectations. Measure the page first, inspect all four margins, and reduce the HTML/CSS/JavaScript case.
A CSS-based page-size adjustment does not resolve the discrepancy The available sources do not establish version-independent compatibility behavior for modern browser print CSS, viewport settings, and smart shrinking. Reproduce using the target wkhtmltopdf build and explicit paper settings; avoid assuming browser print behavior transfers unchanged.
A copied image-height workaround does not fit another document An individual 2020 issue participant described calculating image height against A4 content and margins for a page-fill use case; that is not a universal sizing rule. Calculate against the actual page and margins for the specific use case, and validate the generated PDF rather than treating the report as general behavior. See issue #4750.
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 the goal is a screenshot or PDF capture of a public website rather than converting your own local HTML with wkhtmltopdf, ScreenshotNeo offers a one-request screenshot API and MCP server. It is not a drop-in replacement for wkhtmltopdf’s local HTML-to-PDF workflow; it is an alternative for capturing web pages.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
PDF Pro 3 - PDF editor to create, edit, convert and merge PDFs - 100% Compatible with Adobe Acrobat - for Windows 11, 10, 8.1, 7
  • ALL-IN-ONE SOLUTION – read, edit, convert, merge and protect your PDF files
  • MAXIMUM FUNCIONALITY – create interactive forms, compare PDFs, bates numbering, find and replace text or colors, convert documents, OCR engine, comment, highlight, fill out and print forms, document protection and others
  • EASY TO INSTALL AND USE – well-structured user-interface, in-program instructions, free tech support whenever you need it
  • GREAT VALUE FOR MONEY - why spend a fortune if you can have maximum functionality at a reasonable price - this also fits the requirements of companies very well

For example, this cURL call requests a PDF capture of a URL:

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

See the ScreenshotNeo API documentation for request options. The documented example for other capture formats uses this same endpoint:

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

ScreenshotNeo accepts cookie or consent banners like a visitor and removes 60+ known consent platforms, newsletter popups, and chat widgets before capture; each cleanup step can be turned off. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits cost nothing, and response headers indicate the page verdict and billing status. Its MCP server provides take_screenshot, get_page_info, and capture_pdf tools for Claude, Cursor, and other MCP clients. The free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 shots.

Sign up for ScreenshotNeo’s free plan: 1,000 screenshots a month, no card required.

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

Frequently Asked Questions

Why is wkhtmltopdf defaulting to A4?

The wkhtmltopdf usage documentation identifies A4 as the default page size. Set a named size or explicit dimensions when another format is required.

Does wkhtmltopdf support CSS @page sizing consistently?

The available documentation does not establish version-independent compatibility for @page behavior. Reproduce the case on the target build and verify the resulting PDF dimensions directly.

Can ScreenshotNeo convert a local HTML file the way wkhtmltopdf does?

ScreenshotNeo is described here as a website screenshot API and MCP server for capturing web pages. The supplied product details do not establish local-file conversion as a supported workflow.

Quick Recap

Bestseller No. 1
PDF Extra 2024| Complete PDF Reader and Editor | Create, Edit, Convert, Combine, Comment, Fill & Sign PDFs | Lifetime License | 1 Windows PC | 1 User [PC Online code]
PDF Extra 2024| Complete PDF Reader and Editor | Create, Edit, Convert, Combine, Comment, Fill & Sign PDFs | Lifetime License | 1 Windows PC | 1 User [PC Online code]
READ and Comment PDFs – Intuitive reading modes & document commenting and mark up.; CREATE, COMBINE, SCAN and COMPRESS PDFs
$99.99
Bestseller No. 2
MobiPDF Lifetime - Professional PDF Editor for Windows | Edit, Sign & Convert PDFs | Best Adobe Acrobat Pro Alternative | Lifetime License
MobiPDF Lifetime - Professional PDF Editor for Windows | Edit, Sign & Convert PDFs | Best Adobe Acrobat Pro Alternative | Lifetime License
Edit PDFs with Ease. Modify text, images, and layouts directly within your PDF documents.; Convert & Organize. Export PDFs to Word, Excel, or ePub, and organize files with ease.
$99.99
Bestseller No. 3
Adobe Acrobat Pro | PDF Software | Convert, Edit, E-Sign, Protect | PC/Mac Online Code | Activation Required
Adobe Acrobat Pro | PDF Software | Convert, Edit, E-Sign, Protect | PC/Mac Online Code | Activation Required
Edit text and images without jumping to another app.; Convert PDFs to editable Microsoft Word, Excel, or PowerPoint documents.
$239.88
Bestseller No. 4
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. 5
PDF Pro 3 - PDF editor to create, edit, convert and merge PDFs - 100% Compatible with Adobe Acrobat - for Windows 11, 10, 8.1, 7
PDF Pro 3 - PDF editor to create, edit, convert and merge PDFs - 100% Compatible with Adobe Acrobat - for Windows 11, 10, 8.1, 7
ALL-IN-ONE SOLUTION – read, edit, convert, merge and protect your PDF files
$29.99

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 *

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

Read next

Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
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.