DriversRecommendedOutdated drivers can make a good PC feel brokenScan driver issues before chasing fixes manually.Scan NowOctober 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 Now×
Skip to content
PDF

How to Set Screen Resolution for wkhtmltopdf on a Windows Virtual Server

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

Short answer: set the Windows virtual or RDP session to the dimensions you need, then set wkhtmltopdf’s --viewport-size explicitly. These controls are related but not interchangeable: --viewport-size 1920x1080 emulates a WebKit browser viewport; it does not change Windows’ display resolution or the values exposed by window.screen. PDF paper geometry is controlled separately with page-size, margins, DPI, zoom and shrinking options.

Understand the three different “sizes”

Most inconsistent output comes from treating a browser viewport, a Windows display and a PDF page as the same thing. They are not.

Setting Changes Does not change
RDP Display tab or desktopwidth/desktopheight The dimensions negotiated for the Windows remote session PDF paper dimensions by itself
Set-DisplayResolution The display resolution on supported Windows Server Core installations RDP client dimensions that are negotiated separately
--viewport-size WxH The WebKit window/viewport used while rendering HTML The host’s physical or virtual monitor resolution
--page-size, --page-width, --page-height PDF page geometry CSS viewport metrics unless another option changes layout
--dpi, --zoom and smart shrinking Scaling and conversion behavior The Windows session’s negotiated display size

The wkhtmltopdf manual documents --viewport-size as a viewport/window option. The project’s maintainer has also explained that changing actual screen resolution requires Xvfb with --use-xserver; that advice concerns Linux/X11, not native Windows.

Choose the target dimensions and the output goal

Pick an explicit pair, such as 1920×1080 or 1366×768. Decide which of these you actually need:

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.
#1 Best Overall
Sale
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
  • CSS screen behavior: media queries, JavaScript screen metrics or responsive breakpoints must see the intended session/viewport dimensions.
  • PDF paper geometry: the document must be A4, Letter or a custom physical size. Pixels alone cannot guarantee a particular PDF page size.
  • Both: configure the Windows/RDP session and the wkhtmltopdf layout flags independently, then test in the same execution context used in production.

Set the Windows resolution through Remote Desktop

Use the Remote Desktop Connection interface

  1. On the computer that will connect, open Remote Desktop Connection (mstsc.exe).
  2. Choose Show Options, then open the Display tab.
  3. Move the display-size slider to the required dimensions, or select the closest available setting. A multi-monitor selection can change the effective desktop in ways a single-monitor test does not.
  4. Connect to the virtual server and run wkhtmltopdf inside that session.

The selected size belongs to that RDP connection. Reconnecting with another client, display setting or monitor arrangement can produce different screen metrics even when the server itself has not changed.

Make the dimensions repeatable with an .rdp file

Save the connection settings, open the resulting .rdp file in a text editor and set the desktop dimensions:

desktopwidth:i:1920
desktopheight:i:1080

Open that saved file with Remote Desktop Connection and launch the conversion from the resulting session. Keep the file under deployment control so scheduled operators and troubleshooting sessions use the same dimensions.

Set a display on Windows Server Core

On a supported Server Core installation, run PowerShell as an administrator:

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.
Set-DisplayResolution -Width 1920 -Height 1080 -Force

The cmdlet accepts width and height in pixels; -Force suppresses the confirmation prompt. Microsoft examples also show 1920×1200 and 1024×768. This command addresses the Server Core display. It does not override dimensions that an RDP client negotiates for its own remote session, so check the effective session after connecting.

If the cmdlet is missing, the machine may not be Server Core, the display may be supplied by a virtual driver, or RDP may be controlling the dimensions. In those cases use the RDP configuration path and record the dimensions visible to the conversion process.

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

Configure wkhtmltopdf’s viewport and PDF layout

Set the viewport explicitly

Run wkhtmltopdf with the viewport target and a separate paper setting:

wkhtmltopdf --viewport-size 1920x1080 --page-size A4 input.html output.pdf

--viewport-size affects the browser-like area in which WebKit lays out the page. --page-size A4 controls the PDF sheet. Replace A4 with Letter or use --page-width and --page-height for custom geometry.

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

Choose screen or print media intentionally

wkhtmltopdf generally renders screen styles. Add --print-media-type only when your stylesheet deliberately defines the desired print layout. If the page is designed around screen breakpoints, forcing print media can remove or rearrange content unexpectedly.

Control scaling and shrinking

Paper dimensions, margins, DPI, zoom and smart shrinking all influence where content lands on a PDF page. A 1920-pixel viewport does not produce a 1920-pixel-wide physical PDF page. When exact geometry matters, set the paper size, margins, --dpi and --zoom deliberately, and evaluate whether smart shrinking should remain enabled for your document.

Verify the same context used in production

  1. Check the installed build:
wkhtmltopdf --version

The project download page lists version 0.12.6, released June 11, 2020, as the stable series and provides Windows installers. Treat the installed version as a deployment dependency; do not assume a developer workstation has the same build.

  1. Log the RDP or interactive-session dimensions, the command line, the account running the job and the output path.
  2. Run a diagnostic HTML file that prints window.innerWidth, window.innerHeight, screen.width and screen.height, then convert it in the target session.
  3. Compare an RDP-launched conversion with the scheduled or service-launched conversion. A background service without an interactive display can expose different metrics.
  4. Inspect the PDF’s page size separately from the diagnostic viewport values.

This is an environment check, not a promise that wkhtmltopdf normalizes all session differences. The execution identity and interactive-display availability are part of the rendering conditions.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
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.

Common problems and precise fixes

--viewport-size changes nothing about CSS screen media

Cause: viewport emulation is not an operating-system display change.

Fix: set the RDP dimensions or the Server Core display first, then retain --viewport-size for WebKit layout. Test screen.width and viewport values independently.

The PDF is still the wrong physical size

Cause: viewport pixels do not define PDF paper geometry.

Fix: configure --page-size or custom page dimensions, margins, DPI and zoom. Review smart-shrinking behavior rather than increasing the viewport and expecting a larger sheet.

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

Server Core’s display command is unavailable

Cause: the host is not a supported Server Core environment, or a virtual display/RDP client controls the effective dimensions.

Fix: configure the RDP client or saved .rdp file and measure the actual session in which wkhtmltopdf runs.

Rank #4
Samsung 27" Essential S3 (S36GD) Series FHD 1800R Curved Computer Monitor
  • 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

RDP output differs from a scheduled task

Cause: different identities, desktops or interactive-session availability.

Fix: run diagnostics under the scheduled identity, compare session dimensions and permissions, and make the production task use a deliberately configured interactive or virtual display strategy. Do not “fix” an environment discrepancy by changing unrelated PDF flags.

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

A Linux Xvfb recipe was copied to Windows

Cause: Xvfb is an X11 virtual framebuffer. The maintainer’s Xvfb recommendation is for Linux.

Fix: use Windows RDP/Server Core display controls on native Windows. If your architecture can move rendering to Linux, evaluate Xvfb there as a separate design rather than treating it as a Windows command.

The conversion fails or hangs

  • Confirm the executable path and version with wkhtmltopdf --version.
  • Check that the conversion account can read local files and reach every required URL.
  • Use a bounded wait strategy in the calling service and capture stderr.
  • Test a minimal local HTML file to distinguish an environment problem from page JavaScript, networking or resource-loading issues.

Untrusted HTML creates a security risk

The wkhtmltopdf project warns not to process untrusted HTML without sanitizing user-supplied HTML and JavaScript; malicious content can lead to complete takeover of the server running the converter. Isolate conversion, restrict outbound access where practical, sanitize input and avoid granting the converter unnecessary credentials.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

PowerShell automation example

This example configures Server Core, verifies wkhtmltopdf and performs a conversion. Run it elevated where required, and adapt paths to your installation:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
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.
Set-DisplayResolution -Width 1920 -Height 1080 -Force

$wk = "C:Program Fileswkhtmltopdfbinwkhtmltopdf.exe"
& $wk --version
& $wk --viewport-size 1920x1080 --page-size A4 `
  "C:jobsinput.html" "C:jobsoutput.pdf"
if ($LASTEXITCODE -ne 0) { throw "wkhtmltopdf failed with exit code $LASTEXITCODE" }

For an RDP-controlled server, omit Set-DisplayResolution and ensure the process is launched from the saved RDP session configured with desktopwidth:i:1920 and desktopheight:i:1080.

Or skip the browser setup

If your actual requirement is a clean website screenshot or PDF rather than a wkhtmltopdf process tied to a Windows desktop, ScreenshotNeo provides an HTTP API and MCP server. It accepts consent banners before capture and removes more than 60 known consent platforms, newsletter popups and chat widgets. Bot checks, blank pages, timeouts, failed loads and cache hits are not billed, and response headers identify the page verdict and billing status.

One GET request is enough for a screenshot:

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 documentation for all options, including PNG, JPEG or WebP output, full-page capture with lazy images, CSS-selector elements, device presets, custom viewport and retina scale, PDF paper settings, custom CSS/JavaScript, waits, request blocking, cookies and headers, timezone/geolocation, caching, signed links, asynchronous webhooks, bulk capture and usage reporting.

Python

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)

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}`);

ScreenshotNeo includes 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 shots per month without a card; paid plans start at $5 for 3,000 shots. Create a free ScreenshotNeo account.

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

Which approach fits your deployment?

Requirement Use
CSS breakpoints must match a Windows desktop RDP dimensions or Server Core display, plus an explicit wkhtmltopdf viewport
Exact A4, Letter or custom PDF pages wkhtmltopdf page-size/width/height, margins, DPI and zoom
Background conversion must match an RDP test Standardize identity, session type and display context before tuning flags
Native Windows host with no X11 Do not use Xvfb instructions; configure Windows display/session settings
Clean screenshots or PDFs without maintaining a browser desktop ScreenshotNeo API or MCP server

Frequently Asked Questions

Does wkhtmltopdf’s –viewport-size set Windows to 1920×1080?

No. It emulates the WebKit viewport. Set the RDP or Windows display separately when screen metrics matter.

Can I use Xvfb on a Windows virtual server?

Not as a native Windows fix. Xvfb is an X11/Linux virtual framebuffer; use RDP or Server Core display controls on Windows.

Why is a 1920×1080 viewport not a 1920×1080 PDF page?

PDF paper geometry is controlled by page-size or custom dimensions, margins, DPI, zoom and shrinking, not viewport pixels.

What should I test after changing the RDP size?

Run a diagnostic page in the same account and execution context as production, checking both viewport values and screen values, then inspect PDF page geometry separately.

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

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.

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
Windows Errors? Fix Them Before They SpreadFree repair scan
Crashes, No Sound, or Screen Glitches?Free driver 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.