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.

Use mm and cm directly on the CSS property that controls the element you want to size, then set the PDF sheet independently with wkhtmltopdf options. For example, width: 50mm creates a 50-millimeter CSS box, while --page-width 210mm --page-height 297mm defines an A4-sized page. Margins, scaling and the installed wkhtmltopdf build determine how that layout appears in the final PDF, so render and measure a representative page when physical accuracy matters.

Use metric units in the CSS itself

Millimeters and centimeters are CSS absolute length units. The CSS Values and Units specification defines 1mm as one tenth of 1cm. Put the unit on every declaration that represents a physical dimension; a bare number is not a millimeter or centimeter value.

.label {
  width: 50mm;
  height: 30mm;
  margin: 1.2cm;
  padding: 2mm;
  border: 0.3mm solid #222;
}

This sizes the element in the document layout. It does not change the PDF paper. A class can therefore be 50mm wide on either an A4 page or a custom 100mm-wide page; the page geometry is a separate wkhtmltopdf setting.

Which CSS properties accept these units?

  • width and height for the content box (or the border box when you use box-sizing: border-box).
  • padding, margin, top, right, bottom and left.
  • Border widths, column gaps and other length-valued properties.

Remember that padding and borders add to the outer size under the default content-box model. If a label must remain exactly 50mm including its padding and border, use:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter
  • Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
  • Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
  • Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
  • Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
  • 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.
.label {
  box-sizing: border-box;
  width: 50mm;
  height: 30mm;
  padding: 2mm;
  border: 0.3mm solid #222;
}

How CSS millimeters map to pixels

WebKit’s historical absolute-unit convention treats 1in as 96 CSS pixels. Consequently, 1cm is 96/2.54, approximately 37.795 CSS pixels, and 1mm is 96/25.4, approximately 3.7795 CSS pixels. These conversions explain the layout model; they are not a guarantee that every printer or downstream wkhtmltopdf build will produce identical measured output.

CSS value CSS-pixel equivalent under the 96-pixel-per-inch convention Typical use
1mm 96/25.4 (about 3.7795px) Fine spacing, borders and labels
1cm 96/2.54 (about 37.795px) Margins, cards and larger blocks
1in 96px Reference for absolute-unit conversion

Use the metric unit in your source rather than converting everything to pixels yourself. That keeps the intent visible and lets you change the page or component size without recalculating CSS values.

Set the PDF page separately

wkhtmltopdf provides a paper-size preset and explicit page dimensions. A4 is the documented default page size, but specifying it makes scripts self-documenting. The following command creates a 210mm by 297mm page:

wkhtmltopdf 
  --page-width 210mm 
  --page-height 297mm 
  input.html output.pdf

For a standard format, use the preset instead:

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

Use explicit width and height for labels, tickets or other nonstandard sheets. Keep the page dimensions and the CSS component dimensions conceptually separate: page width is the available sheet, while a CSS width: 50mm is the element’s requested size inside that sheet.

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

Margins are another independent measurement

Set the four PDF margins explicitly when the printable area matters. The usage documentation describes these margin options in millimeters:

Rank #2
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter
  • 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
  • 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
  • Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
  • 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
  • What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.
wkhtmltopdf 
  --page-size A4 
  --margin-top 10mm 
  --margin-right 10mm 
  --margin-bottom 10mm 
  --margin-left 10mm 
  input.html output.pdf

If a block is 50mm wide and the page has 10mm left and right margins, the block is laid out within the remaining content area. Do not add the PDF margins to the element’s CSS width unless you intentionally want extra whitespace around that element.

A complete metric-size example

This document defines an A4 sheet, a 50mm by 30mm label, and a repeated grid. The page options belong to the command; the physical component dimensions belong to CSS.

<!doctype html>
<html>
<head>
  <meta charset="utf-8">
  <style>
    @page { margin: 0; }
    html, body { margin: 0; padding: 0; }
    .sheet {
      width: 210mm;
      min-height: 297mm;
      padding: 10mm;
      box-sizing: border-box;
    }
    .label {
      box-sizing: border-box;
      display: inline-block;
      vertical-align: top;
      width: 50mm;
      height: 30mm;
      margin: 0 3mm 3mm 0;
      padding: 2mm;
      border: 0.3mm solid #222;
      font: 10pt Arial, sans-serif;
    }
  </style>
</head>
<body>
  <main class="sheet">
    <div class="label">Label 1</div>
    <div class="label">Label 2</div>
    <div class="label">Label 3</div>
  </main>
</body>
</html>
wkhtmltopdf --page-size A4 input.html labels.pdf

If you use a full-width sheet wrapper, account for its padding with box-sizing: border-box; otherwise the padding is added outside the declared width.

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

Control scaling: smart shrinking and DPI

Smart shrinking is enabled by default in the documented project usage. It lets WebKit scale a page so content fits, but the effective pixel-to-DPI ratio is then not constant. A layout that looks correct on screen can therefore measure differently when it barely fits or overflows.

For a controlled layout, test with smart shrinking disabled:

Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter
  • Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
  • Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
  • Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
  • Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
  • What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
wkhtmltopdf 
  --disable-smart-shrinking 
  --page-size A4 
  input.html output.pdf

Disabling it can preserve the intended proportional relationship, but it can also produce overflow or additional pages. There is no universal best setting: choose between automatic fit and more predictable scaling for the document you are generating, then inspect the resulting PDF.

The documented --dpi option defaults to 96. Its documentation also notes that it has no effect on X11-based systems. A DPI flag alone is therefore not proof of exact physical output across operating systems, patched Qt builds or downstream packages.

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

Recommended rendering workflow for physical dimensions

  1. Define the geometry in CSS. Put mm or cm on every width, height, margin, padding and border that has a physical requirement.
  2. Choose the paper geometry. Use --page-size for a standard format, or both --page-width and --page-height for custom stock.
  3. Set PDF margins deliberately. Keep them separate from the CSS dimensions of your labels, cards or forms.
  4. Decide how scaling should behave. Start with the default smart shrinking, then compare a render using --disable-smart-shrinking if the layout must retain a controlled scale.
  5. Record the environment. Save the wkhtmltopdf version, build and command-line options with the source HTML.
  6. Measure a representative PDF. Check a page containing the smallest and largest critical dimensions. If the physical size is contractual, measure the generated PDF or a printed sample instead of assuming the CSS value is a certification.

Or skip the browser setup

If your goal is a rendered page image or PDF rather than a locally managed wkhtmltopdf process, ScreenshotNeo provides a single HTTP request. Its API can return PNG, JPEG, WebP or PDF, and its options include page dimensions, margins, full-page capture, waiting rules, custom CSS and JavaScript, resource blocking and other capture controls. See the ScreenshotNeo documentation for the parameter reference.

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
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)
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);

Before capture, ScreenshotNeo accepts cookie or consent banners and removes more than 60 known consent platforms, newsletter popups and chat widgets; each cleanup step can be disabled. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads and cache hits cost nothing, and the response reports the page verdict and billing status in X-Page-Verdict and X-Billed headers. An MCP server supplies 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 without a card. Paid plans start at $5 for 3,000 shots; every feature is included on every plan. Create a free ScreenshotNeo account to try it.

Troubleshooting metric layouts

The declaration has no effect

Check that the property has a unit and that the selector actually matches the element. width: 50; is invalid for a normal length; use width: 50mm;. Also check for a later rule, inline style or stylesheet that overrides it.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray
  • Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
  • Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
  • Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
  • Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
  • Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft

Everything is smaller than expected

Smart shrinking may be scaling the page to fit. Render once with --disable-smart-shrinking, compare the page count and inspect overflow. Check that the PDF margins and any wrapper padding have not reduced the available content width.

The element is clipped or moved to another page

Verify the sum of the element width, margins, borders and padding against the page’s usable width. A 210mm page with left and right margins has less than 210mm available for content. Reduce the CSS footprint, change the page width, or revise the grid instead of relying on shrinking.

The measured size changes between machines

Record the exact wkhtmltopdf version and build. Patched Qt/WebKit packages can differ, and the documented DPI behavior varies on X11-based systems. Compare the same HTML, fonts, assets, page options and scaling flags, then measure the output again.

Images or web fonts change the layout

Make sure assets are reachable by the rendering process and have stable intrinsic dimensions. A late-loading image or font can change line wrapping and therefore the physical position of later elements. Use fixed CSS dimensions for critical media and render only after the required resources are available in your application.

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.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Practical limits of “exact” millimeters

CSS gives you a precise layout unit, but the final artifact passes through WebKit layout, wkhtmltopdf scaling, PDF generation and possibly a printer’s own non-printable area. The available documentation defines the units and controls; it does not certify identical physical output for every downstream build. For forms, die lines, labels or regulatory documents, treat the CSS value as the design specification and validate a generated PDF (and, when relevant, a printed sample) with the build you will deploy.

Best Value
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display
  • 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
  • Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
  • Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
  • HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
  • What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.

FAQ

Can I mix millimeters and centimeters in one stylesheet?

Yes. They are both CSS absolute units, so a margin in centimeters can surround a component sized in millimeters. Keep the unit choice consistent with the measurements your design team uses.

Should I use --page-size A4 or explicit dimensions?

Use the preset when the document targets a named standard. Use --page-width and --page-height when the stock is custom or when a script must make the exact sheet geometry explicit.

Does setting --dpi 96 guarantee a 1:1 physical result?

No. The option’s documented default is 96, and its effect is limited on X11-based systems. Smart shrinking, the wkhtmltopdf build and the final print path still need to be controlled and verified.

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

Frequently Asked Questions

Can a CSS millimeter value control the PDF paper size?

No. CSS units size content boxes. Set the sheet independently with wkhtmltopdf’s page-size preset or explicit page-width and page-height options.

Why does disabling smart shrinking sometimes create extra pages?

Without automatic fitting, content keeps its requested scale. If its total width or height exceeds the usable page area, it can overflow or paginate instead of being reduced.

What should I keep for reproducible PDF generation?

Store the source HTML/CSS, wkhtmltopdf version and build, page and margin options, scaling flags, fonts and assets, then remeasure a representative output after environment changes.

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.