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

The reliable way to remove a cookie banner from a wkhtmltopdf capture is to apply a page-specific user stylesheet that hides the banner’s elements. If the banner is injected by JavaScript, diagnose it with --disable-javascript, or remove it with page-specific code supplied through --run-script after the page loads. Add --javascript-delay when the page needs time to settle, then inspect the resulting PDF or image at the real capture size.

Choose the method that matches how the banner appears

Cookie interfaces are not standardized. A banner may exist in the initial HTML, be inserted by JavaScript, or be rendered by a consent-management platform after several network requests. The selector and timing that work on one site can fail on another, so inspect the actual page before writing a command.

Use a stylesheet for a visual-only removal

This is the safest first choice when the rest of the page needs JavaScript. It changes the rendered output, not the website’s consent state. Hiding a dialog does not prove that consent was recorded.

Disable JavaScript as a diagnostic

--disable-javascript prevents web pages from running JavaScript. If the banner disappears, JavaScript is involved. The option can also remove menus, charts, lazy content, and other functionality, so do not use it as the final setting until you compare the page.

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

Run targeted JavaScript after load

--run-script lets you execute code after loading. This is useful for a banner created by a script, but the code must target that site’s DOM and run at the right time.

Wait only when timing is the problem

--javascript-delay sets a post-load wait in milliseconds. A delay allows late page behavior to finish; it does not, by itself, remove a persistent banner.

Inspect the banner and create a user stylesheet

  1. Open the URL in a normal browser.
  2. Use developer tools to select the consent dialog, its overlay, and any fixed container that could remain behind it. Record stable IDs, classes, or attributes rather than generated names.
  3. Check whether the element is inside an iframe or shadow root. A stylesheet applied to the top document may not reach content isolated there.
  4. Create a CSS file containing only the selectors needed for the capture.

For example, if inspection shows a dialog with #cookie-consent and an overlay with .cookie-backdrop:

#cookie-consent,
.cookie-backdrop {
  display: none !important;
}

Save it as hide-cookie.css. The !important flag helps override inline or high-specificity rules, but use narrow selectors so you do not hide legitimate page content.

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

Render a PDF with --user-style-sheet

The command-line option loads a user stylesheet with every page. Use a file URL for a local CSS file:

#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.
wkhtmltopdf 
  --user-style-sheet "file:///absolute/path/hide-cookie.css" 
  https://example.com/article 
  article.pdf

On Windows, use a correctly formed file URL such as file:///C:/captures/hide-cookie.css. Keep the output path writable. The official references document this setting as “Specify a user style sheet, to load with every page” in the page and loading settings and the command-line usage guide.

Control the viewport and page size

Cookie dialogs can appear only at a particular viewport. Reproduce the production capture dimensions instead of testing only at your monitor’s size:

wkhtmltopdf 
  --viewport-size 1366x768 
  --user-style-sheet "file:///absolute/path/hide-cookie.css" 
  https://example.com/article article.pdf

Confirm that your installed build supports the options you use. Distribution packages can differ from the upstream documentation, and some builds carry patches or feature limitations.

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.
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.

When JavaScript inserts the banner

First compare a JavaScript-disabled render

wkhtmltopdf 
  --disable-javascript 
  https://example.com/article no-js.pdf

If no-js.pdf has no banner but also loses required content, JavaScript is the cause but disabling it is too broad. Keep JavaScript enabled and use a targeted script or stylesheet instead. The usage reference describes this switch as “Do not allow web pages to run javascript.”

Inject a site-specific script

One practical pattern is to pass a JavaScript file that removes known elements:

// remove-cookie.js
(function () {
  var selectors = ['#cookie-consent', '.cookie-backdrop'];
  selectors.forEach(function (selector) {
    document.querySelectorAll(selector).forEach(function (node) {
      node.remove();
    });
  });
})();

Run it after allowing the page to load:

wkhtmltopdf 
  --run-script "file:///absolute/path/remove-cookie.js" 
  --javascript-delay 1500 
  https://example.com/article article.pdf

The exact timing matters. If the consent code runs after your script, the banner can return. Increase the delay or use a polling script for a known short period:

// remove-when-present.js
(function () {
  var selectors = ['#cookie-consent', '.cookie-backdrop'];
  var stopAt = Date.now() + 5000;
  var timer = setInterval(function () {
    selectors.forEach(function (selector) {
      document.querySelectorAll(selector).forEach(function (node) {
        node.remove();
      });
    });
    if (Date.now() > stopAt) clearInterval(timer);
  }, 100);
})();

This remains implementation-specific. Do not assume that a selector, timer, or consent platform behaves the same after the site redesigns its front end.

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

CSS hiding versus JavaScript removal

Approach Best use Risk What it changes
User stylesheet Banner is present in the DOM and JavaScript-dependent content must remain Selectors can become stale; overlays may use other containers Visual output only
--disable-javascript Quick diagnosis or pages that render acceptably without scripts Breaks script-dependent content and layout Entire page’s script execution
--run-script Banner is injected or needs DOM-specific handling Wrong selector or timing leaves it visible Elements targeted by your script
--javascript-delay Late insertion or layout stabilization Longer renders; waiting alone does not hide a banner Capture timing

Validate the output before automation

  • Open the generated PDF and check every page, including fixed overlays that may appear only after scrolling.
  • Confirm that the article’s text, images, navigation, and interactive content still render as expected.
  • Test at each viewport, user-agent, locale, and URL variant used by your job.
  • Repeat the check after consent-platform or front-end changes; selectors are page-maintenance code.
  • Keep a baseline capture without the hiding rule so accidental content loss is detectable.

Troubleshooting common failures

The banner is still visible

Inspect the final DOM and identify the element actually painted. Add the overlay, backdrop, and fixed wrapper selectors. If it is in an iframe, target the frame’s source or use a page-specific approach that can affect that document; a parent stylesheet generally cannot style cross-document contents.

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.

The page is blank or incomplete

Remove --disable-javascript and render again. The page may require scripts for navigation, data, or lazy images. If it still fails, test the URL directly, check redirects and authentication, and verify that your wkhtmltopdf build can load the site’s TLS and modern web features.

The script runs too early

Increase --javascript-delay and make the script tolerate a missing element. A short polling loop is preferable to an arbitrarily large delay, but always cap it so failed pages do not stall a batch.

The CSS file has no effect

Check the absolute file:/// URL, file permissions, syntax, and selector spelling. Run a tiny test rule such as body { outline: 5px solid red !important; } to prove the stylesheet is being loaded, then remove the diagnostic rule.

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

The page changed after deployment

Consent vendors frequently alter markup and class names. Re-inspect the live page, update the selectors, and keep the rule under version control with the URL and viewport it was written for.

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

Or skip the browser setup

ScreenshotNeo provides a one-request website screenshot API when you do not want to maintain wkhtmltopdf selectors and timing. It accepts cookie and consent banners, removes more than 60 known consent platforms plus newsletter popups and chat widgets before capture, and lets you turn those cleanup steps off. Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed; response headers identify the page verdict and billing result. Its MCP server exposes take_screenshot, get_page_info, and capture_pdf to Claude, Cursor, and other MCP clients.

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

See the ScreenshotNeo documentation for all capture options, including PDF output, selectors, waits, headers, cookies, custom scripts, caching, signed links, asynchronous jobs, webhooks, and bulk capture. The Free plan includes 1,000 screenshots each month with no card; paid plans start at $5 for 3,000. Create a free ScreenshotNeo account.

Operational and cost considerations

Local wkhtmltopdf has no per-render service charge, but you own browser installation, fonts, sandboxing, queue control, retries, and selector maintenance. A longer JavaScript delay increases wall-clock time, especially across batches. For repeatable jobs, pin the wkhtmltopdf build, record command-line options, set an external timeout, and preserve failed PDFs or logs for diagnosis.

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

An API can reduce browser setup and maintenance. ScreenshotNeo’s billing behavior is explicit in response headers: only clean shots are billed, while bot checks, blank pages, timeouts, failed loads, and cache hits cost nothing. Choose based on whether you need an on-host renderer with complete control or a managed capture endpoint and MCP workflow.

Frequently Asked Questions

Does hiding a banner count as accepting cookies?

No. A user stylesheet or DOM-removal script changes the rendered screenshot; it does not establish that the site recorded consent.

Can one universal CSS selector remove every cookie banner?

No. Markup and consent platforms differ, so selectors must be discovered and maintained per page or site.

Why does a PDF differ from what I see in Chrome?

wkhtmltopdf uses its own rendering engine and settings. Viewport, JavaScript timing, fonts, redirects, and unsupported web features can all change the result.

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

Which option should I try first on a JavaScript-heavy page?

Keep JavaScript enabled and start with a narrowly targeted user stylesheet. Use a page-specific post-load script if the banner is injected dynamically.

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.