Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix 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 desk4 min

How to Set the Viewport Size in wkhtmltoimage

Use --width to influence wkhtmltoimage’s layout width, --disable-smart-width for strict handling, and crop options to define exact output bounds.

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.

For wkhtmltoimage, use --width N to influence the page’s screen and layout width; add --disable-smart-width when you need that width to be strict. Set height separately with --height N. To bound the final image to exact dimensions, use the crop options. --viewport-size is not the general screen-resolution control: its documented use is to emulate a window size for custom scrollbars or CSS overflow.

Choose the option that matches what you mean by “viewport”

The term can refer to the width used to lay out a page, the window dimensions seen by page scripts, or the rectangle saved in the image. Those are not interchangeable.

As an Amazon Associate I earn from qualifying purchases.

Goal Option What it does
Influence screen and layout width --width N Sets screen width as a guideline; it may not be strict by default. Debian bookworm wkhtmltoimage manual
Make the requested width strict --disable-smart-width Disables smart-width behavior so the specified width is applied strictly, as documented in the manual.
Set screen height --height N Sets height independently from width and crop bounds.
Define the saved image rectangle --crop-x, --crop-y, --crop-w, --crop-h Specify crop position and dimensions.
Emulate a window size for relevant CSS behavior --viewport-size The wkhtmltopdf usage documentation describes it for custom scrollbars or CSS overflow; it does not itself set general screen resolution. wkhtmltopdf usage documentation

Set a strict width or an exact image rectangle

Set the layout width

Use this when the key requirement is how wide the page is laid out. The manual describes --width as a guideline unless smart-width behavior is disabled:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
wkhtmltoimage --width 1280 --disable-smart-width https://example.com page.png

This requests a 1280-pixel screen width and disables smart width. A page with fixed-width or otherwise inflexible content may still overflow or be cut off rather than reflowing neatly; QtWebKit’s layout notes discuss this limitation. QtWebKit viewport and layout notes

#1 Best Overall
Philips 24 Inch Computer Monitor FHD 100Hz VA VESA Flicker-Free, 241V8LB
  • CRISP CLARITY: This 23.8″ Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
  • INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
  • THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors
  • WORK SEAMLESSLY: This sleek monitor is virtually bezel-free on three sides, so the screen looks even bigger for the viewer. This minimalistic design also allows for seamless multi-monitor setups that enhance your workflow and boost productivity
  • A BETTER READING EXPERIENCE: For busy office workers, EasyRead mode provides a more paper-like experience for when viewing lengthy documents

Set height and crop bounds too

When the output must be a defined rectangle, set width and height, then specify crop position and size. This example requests a 1280-by-1024 rectangle starting at the top-left:

wkhtmltoimage --width 1280 --disable-smart-width --height 1024 
  --crop-x 0 --crop-y 0 --crop-w 1280 --crop-h 1024 
  https://example.com page.png

The width and height options influence rendering dimensions; the crop flags bound the portion included in the output. These are documented option patterns, not a guarantee that every build or webpage will produce identical output. Check the installed binary’s help and version, then inspect the image.

Why –viewport-size may not change the reported screen size

The --viewport-size description appears in the wkhtmltopdf usage documentation, which says: “Set viewport size if you have custom scrollbars or css attribute overflow to emulate window size”. The project changelog lists the option as added in version 0.12.0. Usage documentation · Project changelog

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
Philips 22 Inch Computer Monitor FHD 100Hz VA VESA Flicker-Free, 221V8LB
  • CRISP CLARITY: This 22 inch class (21.5″ viewable) Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
  • 100HZ FAST REFRESH RATE: 100Hz brings your favorite movies and video games to life. Stream, binge, and play effortlessly
  • SMOOTH ACTION WITH ADAPTIVE-SYNC: Adaptive-Sync technology ensures fluid action sequences and rapid response time. Every frame will be rendered smoothly with crystal clarity and without stutter
  • INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
  • THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors

A 2014 project issue about wkhtmltopdf 0.12.0 on CentOS 6.5 reported an 800×600 screen despite a requested viewport size. A maintainer explained that the viewport setting changes the window/viewport, not screen resolution, and noted the behavior of that Linux headless build. Treat the report as historical and build-specific, not as a universal limit for current wkhtmltoimage installations. Project issue 1508

Check your installed build and the resulting image

  1. Check the version and available flags using the installed binary’s help, for example wkhtmltoimage --version and wkhtmltoimage --help.

  2. Use --width for the intended layout width; add --disable-smart-width if you need strict width handling.

    Rank #3
    Dell 24 Monitor - SE2426H - 23.8-inch FHD (1920x1080) 144Hz 1ms Display, in-Plane Switching (IPS) Technology, AMD FreeSync™, TÜV 3-Star 2X HDMI, Tilt
    • Clear visuals. Fluid motion: A 144Hz refresh rate and 1ms MPRT deliver smooth, tear‑free motion across work, gaming, and streaming for clearer, more fluid viewing.
    • Eye comfort: TÜV Rheinland 3‑star* certification reduces harmful blue light while preserving stunning color quality without compromise. *TÜV Rheinland 3-star eye comfort certification.
    • Wide viewing angle: Get consistent views across a wide 178° /178° viewing angle.
    • In-Plane Switching (IPS): See excellent color accuracy and consistency across wide viewing angles with In-plane Switching (IPS) technology.
    • Ultra-thin bezels: Maximize your viewing experience with thin bezels.
  3. Add --height for screen height, and crop flags when you need exact output bounds.

    Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  4. Open the saved file and verify its dimensions and visible content. Requested layout width does not ensure that oversized fixed content will fit inside it.

Troubleshoot viewport and output mismatches

  • The page reports a different screen size. A page’s reported screen dimension can differ from the requested viewport/window. Use --width for screen width, and avoid treating the 2014 800×600 issue as a universal behavior.

    Rank #4
    Sale
    Samsung 27" Essential S3 (S36GD) Series FHD 1800R Curved Computer Monitor | 100Hz, Game Mode, Advanced Eye Comfort, HDMI and D-sub Ports (LS27D366GANXZA)
    • CURVED FOR ENHANCED ENGAGEMENT: An immersive viewing experience with a curved monitor that wraps more closely around your field of vision; It creates a wider view, enhancing depth perception and minimizing peripheral distraction
    • SMOOTH PERFORMANCE FOR SEAMLESS CONTENT: Stay in the action when playing games, watching videos, or working on creative projects; The 100Hz refresh rate reduces lag and motion blur so you don't miss a thing in fast-paced moments¹
    • MORE GAMING POWER: Gain the edge with optimizable game settings; Color and image contrast can be adjusted to see scenes more vividly and spot enemies hiding in the dark; Game Mode adjusts any game to fill the screen so you can view every detail²
    • KEEP IT EASY ON THE EYES: Care for your eyes and stay comfortable, even during long sessions; Advanced eye comfort technology certified by TÜV reduces eye strain by minimizing blue light and reducing irritating screen flicker²
    • INCREASED VERSATILITY: Connect to more; Plug devices straight into your monitor for increased flexibility, making your computing environment even more convenient
  • The output is wider than expected. --width is a guideline by default. Try --disable-smart-width, then inspect whether the page itself contains fixed-width elements.

  • Content is clipped or overflows. A forced width cannot make non-flexible content responsive. Adjust the page’s CSS if you control it, or choose crop coordinates and dimensions that capture the intended portion.

    Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • The saved image has the wrong bounds. Screen dimensions and output cropping are separate. Set --crop-x, --crop-y, --crop-w, and --crop-h explicitly.

    Best Value
    Sale
    Sceptre New 22-Inch Gaming Monitor, FHD 1080p, Up to 144Hz, HDMI, DisplayPort, Built-in Speakers, Machine Black (E225W-FW144 Series, 2026)
    • 【INTEGRATED SPEAKERS】Whether you're at work or in the midst of an intense gaming session, our built-in speakers provide rich and seamless audio, all while keeping your desk clutter-free.
    • 【EASY ON THE EYES】 Protect your eyes and enhance your comfort with Blue-Light Shift technology. This feature reduces harmful blue light emissions from your screen, helping to alleviate eye strain during long hours of use and promoting healthier viewing habits.
    • 【WIDEN YOUR PERSPECTIVE】Our sleek minimal bezel design ensures undivided attention. The nearly bezel-free display seamlessly connects in a dual monitor arrangement, delivering an unobstructed view that lets you focus on more at once, completely distraction-free.
  • A flag is unavailable or behaves differently. Check the installed binary’s help and version. wkhtmltoimage uses Qt WebKit and can vary by build and platform; the project repository was archived on 2023-01-02. wkhtmltopdf project repository

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 hosted screenshot rather than a local wkhtmltoimage rendering, ScreenshotNeo takes a screenshot or PDF with one GET request. It accepts cookie and consent banners and removes 60+ known consent platforms, newsletter popups, and chat widgets before capture; each step can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers identify the page verdict and billing status. Its MCP server lets AI agents use take_screenshot, get_page_info, and capture_pdf. The free plan includes 1,000 shots a month with no card; paid plans start at $5 for 3,000 shots. Every feature is on every plan.

Example cURL request (replace YOUR_API_KEY with your key):

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://example.com -o shot.webp

See the ScreenshotNeo API documentation for options and response details. Sign up for 1,000 free screenshots a month with no card.

Frequently Asked Questions

Does –width set the height of the screenshot?

No. Use –height to set screen height; crop height is set separately with –crop-h.

Is –viewport-size a wkhtmltoimage screen-resolution flag?

The documented viewport-size description is in wkhtmltopdf usage documentation and concerns emulating window size for custom scrollbars or CSS overflow, not general screen resolution.

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.

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
Outdated Drivers Are Slowing You DownFree scan - exact matches
PC Slower Than It Used to Be?Free scan - under a minute

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.