Set the virtual display when you start xvfb-run. Pass Xvfb a screen definition in the form WIDTHxHEIGHTxDEPTH through --server-args:
xvfb-run --server-args="-screen 0 1920x1080x24" wkhtmltopdf --use-xserver input.html output.pdf
xvfb-run --server-args="-screen 0 1920x1080x24" wkhtmltoimage --width 1920 --height 1080 --disable-smart-width input.html output.png
Here, 1920 is the virtual screen width, 1080 is its height and 24 is the color depth. Set this explicitly instead of relying on a distribution’s default geometry.
What the resolution setting actually controls
A headless conversion involves two layers:
- Xvfb/Xvfb-run: creates the virtual X11 display. Its
-screenargument defines the display’s width, height and color depth. - wkhtmltopdf or wkhtmltoimage: renders the page inside that display and can apply its own viewport or image-size settings.
These settings are related but not interchangeable. Changing wkhtmltopdf’s DPI does not resize the X11 display. Likewise, changing an image’s output width does not necessarily enlarge the virtual desktop available to the renderer.
Use the correct Xvfb syntax
Screen geometry format
Xvfb expects:
-screen screennum WIDTHxHEIGHTxDEPTH
For the first display, use screen number 0. For example, -screen 0 1366x768x24 creates a 1366 by 768 display with 24-bit color depth. The final value is color depth, not a second width or a DPI value.
#1 Best Overall
- 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
Passing it through xvfb-run
xvfb-run forwards server options with --server-args. Quote the complete argument so the shell passes it as one value:
xvfb-run --server-args="-screen 0 1366x768x24" wkhtmltopdf --use-xserver page.html page.pdf
For a 1920×1080 render:
xvfb-run --server-args="-screen 0 1920x1080x24" wkhtmltopdf --use-xserver page.html page.pdf
Some packaged builds can render without an X server, while others require one. --use-xserver tells wkhtmltopdf to use the X display created by xvfb-run when the build needs it.
Set wkhtmltoimage’s viewport and output size
wkhtmltoimage has renderer-specific controls in addition to Xvfb geometry:
xvfb-run --server-args="-screen 0 1920x1080x24"
wkhtmltoimage --width 1920 --height 1080 --disable-smart-width
https://example.com capture.png
What –width and –height do
--widthsets the screen-width guide used by wkhtmltoimage, in pixels.--heightsets the screen-height guide.--disable-smart-widthprevents automatic widening when the document’s content exceeds the requested width.
Keep the requested viewport no larger than the Xvfb screen when you want predictable CSS media queries and layout. A wider wkhtmltoimage setting than the virtual display can produce wrapping or clipping that differs from a real browser.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Rank #2
- 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
Capturing one viewport versus the full page
For a fixed viewport screenshot, use matching Xvfb and image dimensions. For a tall page, keep the desired width and use wkhtmltoimage’s full-page behavior supported by your installed build; the virtual display still needs a width sufficient for the layout. Test pages with lazy-loaded content separately because older WebKit-based builds may not trigger every modern loading path.
wkhtmltopdf: page layout, DPI and X geometry
For PDF output, Xvfb controls the available virtual desktop while wkhtmltopdf controls document layout, paper format and margins. A typical command is:
xvfb-run --server-args="-screen 0 1920x1080x24"
wkhtmltopdf --use-xserver --page-size A4 --margin-top 12mm
--margin-right 12mm --margin-bottom 12mm --margin-left 12mm
https://example.com output.pdf
The --dpi option changes output scaling calculations for formats that use DPI; it does not change X11 geometry on X11-based systems. If a page is still laid out as though it were 800 pixels wide, adjust the Xvfb screen and wkhtmltopdf’s relevant width or viewport options rather than increasing DPI.
Reliable command patterns
Local HTML to PNG
xvfb-run --server-args="-screen 0 1600x900x24"
wkhtmltoimage --width 1600 --height 900 --disable-smart-width
file:///absolute/path/page.html page.png
Remote HTML to PNG
xvfb-run --server-args="-screen 0 1440x900x24"
wkhtmltoimage --width 1440 --height 900 --disable-smart-width
https://example.com page.png
Local HTML to PDF
xvfb-run --server-args="-screen 0 1920x1080x24"
wkhtmltopdf --use-xserver file:///absolute/path/page.html page.pdf
Use a shell variable
GEOMETRY="-screen 0 1920x1080x24"
xvfb-run --server-args="$GEOMETRY" wkhtmltopdf --use-xserver input.html output.pdf
Using one variable in scripts makes the chosen geometry visible and keeps PDF and image jobs consistent.
Windows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallOutdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchRank #3
- 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.
Checking what your build is using
- Run
xvfb-run --helpand confirm that your package exposes--server-args. - Run
wkhtmltopdf --versionandwkhtmltoimage --version; distribution packages can differ in X-server requirements and available switches. - Render a test page containing
window.innerWidthor a CSS media-query indicator, then inspect the result. - Compare the generated image dimensions with the requested
--widthand--height. A PNG’s pixel dimensions verify output size, but they do not by themselves prove the Xvfb geometry was sufficient.
Do not assume the default display size. Debian testing documents a 1280×1024×24 default, while older Ubuntu and Debian packages document other defaults. Explicit --server-args is the portable choice.
Common problems and fixes
“Cannot connect to X server”
Cause: the command was run without xvfb-run, or a build that needs X was not given --use-xserver.
Fix: wrap the command with xvfb-run --server-args="-screen 0 1920x1080x24" and add --use-xserver to wkhtmltopdf.
The image is still 800×600
Cause: Xvfb geometry and wkhtmltoimage output settings were left at defaults.
Fix: set both -screen 0 WIDTHxHEIGHTxDEPTH and matching --width/--height; add --disable-smart-width when width must be strict.
Changing –dpi did nothing
Cause: DPI is not an X11 screen-size control.
Fix: change the Xvfb -screen value and the renderer’s viewport settings.
Rank #4
- 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
Content is clipped or wraps differently
Cause: the requested renderer width exceeds the virtual display, smart-width expanded the layout, or CSS media queries selected a different breakpoint.
Fix: make Xvfb width at least the intended viewport width, use --disable-smart-width, and test at the exact width your application expects.
The command works locally but fails in CI
Cause: different package versions, missing fonts, restricted network access, or a display-number collision.
Fix: pin the wkhtmltopdf/wkhtmltoimage and Xvfb packages, install required fonts, use absolute file URLs, allow required outbound requests, and let xvfb-run select a free display rather than exporting a fixed DISPLAY.
JavaScript content is blank
Cause: the page finished before asynchronous content loaded, scripts failed, or the old WebKit engine cannot execute a modern feature.
Fix: use the wait options available in your installed wkhtmltoimage/wkhtmltopdf build, inspect stderr, and verify the page in a compatible browser. Increasing Xvfb resolution will not repair a JavaScript error.
Choosing geometry for reproducible output
| Goal | Xvfb setting | Renderer setting | Notes |
|---|---|---|---|
| Desktop-like screenshot | -screen 0 1920x1080x24 |
--width 1920 --height 1080 --disable-smart-width |
Use matching dimensions for a fixed viewport. |
| Tablet breakpoint test | -screen 0 1024x768x24 |
--width 1024 --height 768 --disable-smart-width |
Useful for deterministic responsive-layout checks. |
| PDF conversion | At least as wide as the intended layout | Paper, margins and zoom options | DPI does not replace X geometry. |
| Full-page image | Width at least the target CSS viewport | Set width; use the build’s full-page behavior | Very tall pages may consume substantial memory. |
Use 24-bit depth unless a specific application requires another depth. Larger screens and long pages increase memory use; run jobs serially or limit concurrency on small CI workers. Cache static assets locally when possible, and set explicit timeouts in the surrounding job because neither Xvfb nor wkhtml tools guarantees that a remote site will respond.
Do these 3 things before closing this tab:
1Repair Windows errors before they cause bigger problems2Scan for outdated or missing drivers - takes under a minute3Clear out junk files and repair common Windows errorsBest Value
- 【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.
Library and API users
Bindings often expose a screenWidth setting and a smartWidth switch. Treat these as renderer settings, not replacements for Xvfb geometry. Set the binding’s screen width to the same target used in -screen 0 WIDTHxHEIGHTxDEPTH, and disable smart width when exact layout width matters. The exact property names and defaults depend on the language binding, so inspect that binding’s versioned documentation.
Or skip the browser setup
If you only need a clean website screenshot, ScreenshotNeo provides a single HTTP request instead of maintaining Xvfb and wkhtml binaries. It accepts cookie and consent banners like a visitor, removes more than 60 known consent platforms plus newsletter popups and chat widgets, and bills only clean shots: bot checks or CAPTCHAs, blank pages, timeouts, failed loads and cache hits are not billed. Each response identifies the result with X-Page-Verdict and X-Billed headers.
See the ScreenshotNeo documentation for all options, including viewport and device presets, full-page capture with lazy images loaded, CSS-selector element capture, dark mode, retina scale, PDF output, custom CSS and JavaScript, click and wait actions, request blocking, headers, cookies, user agents, timezone, geolocation, transparent backgrounds, resizing, TTL caching, signed links, asynchronous webhooks, bulk capture and usage reporting.
cURL
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
Python
import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
r.raise_for_status()
open("shot.webp", "wb").write(r.content)
Node.js
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
if (!res.ok) throw new Error(`HTTP ${res.status}`);
const fs = await import('node:fs/promises');
await fs.writeFile('shot.webp', Buffer.from(await res.arrayBuffer()));
ScreenshotNeo also has an MCP server with 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 screenshots, and every feature is included on every plan. Create a free ScreenshotNeo account.
Free tools Windows power users keep installed
One-click scans. No signup required.
Frequently Asked Questions
Does -screen 0 1920x1080x24 make the PDF 1920 pixels wide?
No. It defines the X11 display available to the renderer. PDF paper size, margins, zoom and related wkhtmltopdf options determine the document’s page output.
Can I use a color depth other than 24?
Xvfb accepts another depth value, but 24 is the conventional choice for web rendering. Change it only when your application or package requires a different visual format.
Should I export DISPLAY manually?
Normally no. xvfb-run starts Xvfb, chooses a display and sets DISPLAY for the wrapped command. Manually exporting a fixed display can cause collisions in parallel jobs.
Why does a modern site render differently in wkhtml tools?
wkhtmltopdf and wkhtmltoimage use an older WebKit-based engine in many packages. Differences can come from unsupported CSS or JavaScript, not from Xvfb resolution.
Quick wins for a faster PC:
Clear out junk files and repair common Windows errorsFree Scan →Scan for outdated or missing drivers - takes under a minuteDriver Scan →Quick Recap
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.

