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

To keep a cookie-consent banner out of a PDF or screenshot, hide the specific banner at capture time—not every dialog on the page. For a PDF, use a targeted print stylesheet when your PDF renderer uses print CSS; for a screenshot, inject a targeted stylesheet during capture. In Playwright and Puppeteer, you can also switch PDF rendering to screen media, but that changes the page’s styling context. Check the resulting file to confirm the banner is gone and the page content remains.

First choose the right method for the output

A PDF and an image screenshot can render a page under different rules. Playwright’s page.pdf() uses print CSS by default, as does Puppeteer’s PDF generation. That makes a print-only CSS rule a good fit when the goal is to remove a banner from the PDF without changing the ordinary page view. For an image screenshot, use a screenshot-time stylesheet or another targeted capture-time change.

The correct selector depends on the site’s actual markup. Inspect the banner on the page you are capturing, then test the selector against the produced PDF or image. Avoid broad rules such as hiding every dialog, fixed element, or overlay: those can remove page content or useful controls along with the consent banner.

Situation Starting approach What to verify
You control the site and want the banner omitted only from PDFs Add a targeted rule to the site’s print stylesheet. The PDF omits the banner while the normal on-screen page still shows it.
You do not control the site and generate PDFs with Playwright or Puppeteer Inject a targeted print rule, or use screen media if you specifically need screen styling. The banner is hidden and the page layout and content remain correct.
You capture an image with Playwright Use the screenshot style option to hide the identified element. The selector matches the banner in the captured page, including any relevant frame or shadow root.
You repeatedly capture pages with varying consent interfaces Consider a hosted browser workflow with consent handling, then verify its behavior on your target sites. The service’s handling works for your pages; vendor coverage statements are not a guarantee for every site.

For a site you control: use a print stylesheet

A print-specific rule is usually the least surprising fix when only the PDF should omit the banner. It leaves the screen presentation alone and does not require changing how the page’s normal consent interface works.

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

First inspect the page and find a selector unique to the consent banner. Suppose your site uses .cookie-consent-banner. Add a rule such as:

@media print {
  .cookie-consent-banner {
    display: none !important;
  }
}

Replace that example selector with the one used by your site. If the banner contains content that should appear in printed copies, adjust the rule rather than hiding the entire component. Generate a PDF and inspect multiple pages if the banner is fixed or overlaps content while scrolling.

Playwright: remove a banner from a PDF

Playwright’s page.pdf() generates a PDF with print CSS media. The API also lets you emulate screen media before generating the PDF. Use a targeted print rule when you want only the banner removed under print styling; use screen emulation only when the PDF should follow the page’s screen styles instead.

Inject a targeted print rule

This Node.js example injects a print-only rule before generating a PDF. Change the URL and selector to match the page. Install Playwright in your project and ensure its browser is installed before running the script.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
const { chromium } = require('playwright');

(async () => {
  const browser = await chromium.launch();
  const page = await browser.newPage();
  await page.goto('https://example.com', { waitUntil: 'networkidle' });

  await page.addStyleTag({
    content: `@media print {
      .cookie-consent-banner {
        display: none !important;
      }
    }`
  });

  await page.pdf({ path: 'page.pdf', format: 'A4', printBackground: true });
  await browser.close();
})();

The selector above is illustrative; it will not work unless the target page uses it. If the banner is inserted after navigation, wait for the relevant UI to appear before adding the rule or capturing the PDF. If the page’s content is loaded lazily, confirm that it is present before capture.

Use screen CSS for the PDF

If the desired result is a PDF styled like the screen version of the page, call page.emulateMedia({ media: 'screen' }) before page.pdf():

await page.emulateMedia({ media: 'screen' });
await page.pdf({ path: 'page.pdf', format: 'A4', printBackground: true });

Screen emulation changes the styling context, not just the cookie banner. It may affect layout and backgrounds, so review the PDF rather than assuming it will match the print-media version. PDF options such as paper format, dimensions, margins, background printing, page ranges, and scale shape the output but do not themselves suppress a consent banner.

Playwright: remove a banner from an image screenshot

For screenshots, Playwright’s screenshot style option applies CSS temporarily during capture. The documentation describes it as useful for hiding dynamic elements or making elements invisible; it also says these styles pierce Shadow DOM and apply to inner frames. That can help when a banner is not in the top-level document, though the selector still needs to match the actual element.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
const { chromium } = require('playwright');

(async () => {
  const browser = await chromium.launch();
  const page = await browser.newPage();
  await page.goto('https://example.com', { waitUntil: 'networkidle' });

  await page.screenshot({
    path: 'page.png',
    fullPage: true,
    style: '.cookie-consent-banner { display: none !important; }'
  });

  await browser.close();
})();

Set fullPage to false if you need only the current viewport. If the banner uses a different class, ID, or structure, substitute its real selector. Screenshot-time CSS changes the captured rendering; it does not save a preference or record a consent choice.

Puppeteer: remove a banner from a PDF

Puppeteer’s page.pdf() uses the print CSS media type. For a targeted fix, inject a print rule before generating the PDF:

const puppeteer = require('puppeteer');

(async () => {
  const browser = await puppeteer.launch();
  const page = await browser.newPage();
  await page.goto('https://example.com', { waitUntil: 'networkidle0' });

  await page.addStyleTag({
    content: `@media print {
      .cookie-consent-banner {
        display: none !important;
      }
    }`
  });

  await page.pdf({ path: 'page.pdf', format: 'A4', printBackground: true });
  await browser.close();
})();

To generate the PDF with screen styling instead, call page.emulateMediaType('screen') before page.pdf():

#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.
await page.emulateMediaType('screen');
await page.pdf({ path: 'page.pdf', format: 'A4', printBackground: true });

As with Playwright, screen emulation can change more than the banner’s appearance. Check the document’s layout and content after capture.

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.

Browser Print or Save as PDF

If you own the site, use its print stylesheet so the rule applies consistently when visitors print or save the page as a PDF. If you are capturing a third-party page, you generally cannot edit its site CSS. For a one-off capture, browser developer tools or an automation script can inject a narrowly targeted stylesheet, but the precise steps depend on the browser and the page.

In either case, inspect the page to identify the consent element rather than guessing a generic cookie selector. If a banner is inside a frame or shadow root, a top-level selector may not reach it; use a capture method that can style the relevant context or otherwise target the actual element.

Hosted automation for recurring captures

For repeated screenshot and PDF jobs, a hosted browser service may provide consent-banner handling. Browserless documents a blockConsentModals=true option for its BQL sessions, screenshot, PDF, and other REST endpoints. Its documentation says the feature covers most major consent platforms, naming OneTrust and Cookiebot, and recommends custom selectors for sites it does not handle. Those are vendor statements, not independent evidence that the option works on every page.

Even with a built-in blocker, verify the resulting file for each important site and workflow. A page may use a consent UI the service does not recognize, or a custom selector may be needed.

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.

Or skip the browser setup

ScreenshotNeo is a website screenshot API and MCP server. Make a GET request with the target URL to return an image or PDF. Its capture flow accepts cookie or consent banners like a visitor and removes more than 60 known consent platforms, newsletter popups, and chat widgets; each step can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits cost nothing, and each response includes X-Page-Verdict and X-Billed headers.

For a WebP screenshot, use this cURL call, replacing the URL with the page you need. See the ScreenshotNeo API documentation for the full request options.

curl -G "https://api.screenshotneo.com/v1/shot" 
  -d access_key=YOUR_API_KEY 
  --data-urlencode url=https://example.com 
  -o shot.webp

ScreenshotNeo also has an MCP server with take_screenshot, get_page_info, and capture_pdf tools for Claude, Cursor, and other MCP clients. It includes 1,000 screenshots per month free with no card; paid plans start at $5 for 3,000 screenshots.

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.

Sign up for ScreenshotNeo’s free plan to get 1,000 screenshots a month without a card.

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

Troubleshooting

  • The banner still appears. The selector may not match the live element, or the banner may be added after the stylesheet. Inspect the rendered page, confirm the selector, and apply the rule after the element exists or use screenshot-time styling.
  • The banner disappears on screen but remains in the PDF. A screen-only style may not affect print output. Add a targeted @media print rule, or emulate screen media before PDF generation if screen styling is what you want.
  • The PDF layout changes unexpectedly. Switching to screen media changes the whole styling context. Return to print media and hide only the banner, then review the PDF’s margins, paper size, background printing, and scale.
  • The rule hides the wrong content. The selector is too broad or matches another element. Narrow it to a unique banner element and inspect the PDF or screenshot again.
  • A banner in a frame or shadow root is unaffected. Confirm where the element lives. A top-level injected style may not reach it; Playwright documents that its screenshot style option pierces Shadow DOM and applies to inner frames.
  • The capture is blank or incomplete. Confirm navigation completed and that the content has loaded before capture. For dynamic pages, wait for a relevant selector or other reliable page-ready condition rather than relying only on a fixed delay.

Appearance is not consent

CSS that hides a banner changes what appears in the captured file. It does not, by itself, show that a visitor made a choice or update the site’s consent-management state. If your goal is to record consent, use the site’s actual controls and verify the resulting state. The technical documentation cited here does not establish jurisdiction-specific legal requirements.

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

FAQ

Can I hide every cookie banner with one CSS selector?

No universal selector is established here. Sites use different markup and consent tools, so inspect each target page and test the rule against its output.

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

Does removing the banner mean the site has accepted my cookies?

No. Hiding the interface is not the same as making or recording a consent choice.

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.

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.