A page fetched from the web seldom comes alone: a consent dialog lies over it, a cookie bar under it, and advertisements between its paragraphs. By default Weblitz prints all of it, as a browser does. Two options leave it out. Both are off unless you set them, and neither clicks anything.
Since WeblitzPdf 2.0.0-beta.4.
Consent boxes
Consent = HtmlConsent.Hide leaves consent boxes out of the print. No button is pressed and no answer is given in the reader's name: the page and its consent platform run as they come, and what they show of it is not printed. It hides:
the boxes of the consent platforms most sites use (OneTrust, Sourcepoint, Cookiebot, Didomi, Usercentrics, CookieYes and others), by the platforms' own containers;
what the EasyList Cookie List names, a list of thousands of sites' cookie notices kept by the EasyList authors;
a box of the page's own: one fixed to the window, or a dialog, of a few lines that speaks of cookies, consent or privacy and holds a button to answer with;
the veil such a box puts over the page, and the lock it puts on the page's scrolling, which would cut the print to its first page.
What was hidden is said in the result's notes (code consentHidden), each of the page's own boxes named as a selector names it. A box no rule knows stays: name it in Hide. A site that shows its content only once consent is given prints what it shows without it.
Advertisements and trackers
Ads = HtmlAds.Block prints a page as an ad blocker shows it, by the filter lists EasyList and EasyPrivacy:
a request the lists block is not made: fewer requests, less script to run;
an element they hide is not printed;
a frame or a picture whose request was refused leaves no empty box.
The notes count what was left out (code adsBlocked). AdFilters adds rules of your own in the lists' syntax, a line a rule: ||ads.example.com^ blocks the requests to a host, example.com##.sponsored hides elements on a site, @@ and #@# make exceptions. A site that refuses readers who block its advertisements prints what it shows them.
The lists, and keeping them fresh
The filter lists are the work of the EasyList authors (easylist.to). The package carries a snapshot of EasyList, EasyPrivacy and the EasyList Cookie List as plain files in lists/ beside your application, unchanged, with their notice and licences in lists/NOTICE.txt. The snapshot is as old as the package, and the lists change every day.
var lists = await HtmlToPdf.UpdateFilterListsAsync(); // optional, at start
It is the only thing that fetches the lists: no render ever does, and nothing runs in the background. The copies are kept in a folder (one of your own if you name it) and read again by later runs; a list is not fetched again before its own refresh interval has passed, and one that cannot be fetched leaves the previous copy, or the snapshot, in use, with the reason in the result.
Without the consent boxes
A page from the web often comes with a consent dialog over it and a cookie bar under it. Consent = Hide leaves them out of the print without clicking anything: the page and its consent platform run as they come, no answer is given in the reader's name. It hides the consent platforms' own boxes, the boxes the EasyList Cookie List names, and a box of the page's own (fixed to the window, or a dialog, that speaks of cookies, consent or privacy and holds a button to answer with), with the veil behind it and the lock it puts on the page's scrolling. A consentHidden note says what was hidden.
<!DOCTYPE html>
<html lang="en"><head><meta charset="utf-8"><title>The Daily Example</title>
<style>
body { font: 15px/1.6 Georgia, serif; margin: 0; color: #111827; }
header { padding: 14px 32px; border-bottom: 3px double #111827; font: bold 26px Georgia, serif; }
main { display: flex; gap: 32px; padding: 20px 32px; }
article { flex: 1; }
h1 { font-size: 26px; line-height: 1.25; margin: 0 0 8px; }
.byline { color: #6b7280; font: 12px Arial, sans-serif; margin-bottom: 12px; }
aside { width: 200px; flex: none; }
.slot { display: block; background: #e5e7eb; color: #6b7280; font: 11px Arial, sans-serif; text-align: center; }
.sponsored { margin-top: 16px; padding: 10px; border: 1px solid #d1d5db; font: 12px Arial, sans-serif; }
.sponsored b { display: block; color: #6b7280; text-transform: uppercase; font-size: 10px; }
#veil { position: fixed; inset: 0; background: rgba(17, 24, 39, .55); }
#consent { position: fixed; top: 150px; left: 50%; width: 420px; margin-left: -230px; padding: 20px; background: #fff;
border-radius: 8px; font: 13px/1.5 Arial, sans-serif; box-shadow: 0 8px 30px rgba(0, 0, 0, .3); }
#consent h2 { margin: 0 0 8px; font-size: 17px; }
#consent button { margin: 12px 8px 0 0; padding: 8px 14px; border: 0; border-radius: 4px; background: #111827; color: #fff; }
#cookie-bar { position: fixed; left: 0; right: 0; bottom: 0; padding: 12px 32px; background: #111827; color: #fff;
font: 13px Arial, sans-serif; }
#cookie-bar a { color: #fbbf24; }
</style></head>
<body>
<header>The Daily Example</header>
<ins class="adsbygoogle slot" data-ad-slot="1234567890" style="height: 90px; line-height: 90px; margin: 12px 32px;">Advertisement</ins>
<main>
<article>
<h1>City council approves the new tram line after a decade of debate</h1>
<div class="byline">By a staff reporter · 17 November 2026</div>
<p>The council voted on Tuesday evening to build the line that will link the harbour to the northern districts.
Work is to start in the spring and to last four years, with the first trams running on the southern half two years
earlier.</p>
<p>Supporters called the vote overdue. The line was first proposed in 2016 and has been redrawn three times since,
each time to spare a street its trees or a square its market.</p>
<iframe class="slot" src="https://securepubads.g.doubleclick.net/gampad/adx?slot=inline" width="300" height="250" style="border: 0; margin: 8px 0;"></iframe>
<p>Opponents say the cost, now put at 480 million, will keep rising. The mayor answered that the city could not
afford another decade of buses stuck in the same traffic as the cars they were meant to replace.</p>
<p>The first works will close the harbour road at night from March.</p>
</article>
<aside>
<div class="sponsored"><b>Sponsored</b>Ten gadgets every commuter needs this winter</div>
<div class="sponsored"><b>Sponsored</b>The savings account the banks keep quiet about</div>
</aside>
</main>
<div id="veil" hidden></div>
<div id="consent" role="dialog" aria-modal="true" hidden>
<h2>We value your privacy</h2>
We and our 214 partners use cookies and similar technologies to store and read information on your device, to show
you personalised advertising and to measure its audience.
<div><button>Accept all</button><button>Reject all</button><button>Manage preferences</button></div>
</div>
<div id="cookie-bar" hidden>We use cookies to give you the best experience. <a href="#">Find out more</a> · <a href="#" role="button">OK, I agree</a></div>
<script src="https://www.google-analytics.com/analytics.js" async></script>
<script>
// (as a consent platform does: its boxes appear once the page has loaded)
window.addEventListener('load', function () {
for (const id of ['veil', 'consent', 'cookie-bar']) document.getElementById(id).hidden = false;
});
</script>
</body></html>
Info resourceRefused: Script https://www.google-analytics.com/analytics.js: no resource loader was given (only data: URLs load).
Info resourceRefused: Frame https://securepubads.g.doubleclick.net/gampad/adx?slot=inline: no resource loader was given (only data: URLs load).
Info consentHidden: Consent boxes are not printed (Consent = Hide): the page's own div#consent, the page's own div#cookie-bar.
Info scriptsRan: The page's scripts ran (33 ms of virtual time, 6 tasks; 0 canvases drawn).
Without advertisements and trackers
Ads = Block prints a page as an ad blocker shows it, by the filter lists EasyList and EasyPrivacy (the work of the EasyList authors, a snapshot of which the package carries): a request the lists block is not made, an element they hide is not printed, and a frame whose request was refused leaves no empty box. AdFilters adds rules of your own in the same syntax, here for the page's sponsored boxes. An adsBlocked note counts what was left out. Here with Consent = Hide as well.
<!DOCTYPE html>
<html lang="en"><head><meta charset="utf-8"><title>The Daily Example</title>
<style>
body { font: 15px/1.6 Georgia, serif; margin: 0; color: #111827; }
header { padding: 14px 32px; border-bottom: 3px double #111827; font: bold 26px Georgia, serif; }
main { display: flex; gap: 32px; padding: 20px 32px; }
article { flex: 1; }
h1 { font-size: 26px; line-height: 1.25; margin: 0 0 8px; }
.byline { color: #6b7280; font: 12px Arial, sans-serif; margin-bottom: 12px; }
aside { width: 200px; flex: none; }
.slot { display: block; background: #e5e7eb; color: #6b7280; font: 11px Arial, sans-serif; text-align: center; }
.sponsored { margin-top: 16px; padding: 10px; border: 1px solid #d1d5db; font: 12px Arial, sans-serif; }
.sponsored b { display: block; color: #6b7280; text-transform: uppercase; font-size: 10px; }
#veil { position: fixed; inset: 0; background: rgba(17, 24, 39, .55); }
#consent { position: fixed; top: 150px; left: 50%; width: 420px; margin-left: -230px; padding: 20px; background: #fff;
border-radius: 8px; font: 13px/1.5 Arial, sans-serif; box-shadow: 0 8px 30px rgba(0, 0, 0, .3); }
#consent h2 { margin: 0 0 8px; font-size: 17px; }
#consent button { margin: 12px 8px 0 0; padding: 8px 14px; border: 0; border-radius: 4px; background: #111827; color: #fff; }
#cookie-bar { position: fixed; left: 0; right: 0; bottom: 0; padding: 12px 32px; background: #111827; color: #fff;
font: 13px Arial, sans-serif; }
#cookie-bar a { color: #fbbf24; }
</style></head>
<body>
<header>The Daily Example</header>
<ins class="adsbygoogle slot" data-ad-slot="1234567890" style="height: 90px; line-height: 90px; margin: 12px 32px;">Advertisement</ins>
<main>
<article>
<h1>City council approves the new tram line after a decade of debate</h1>
<div class="byline">By a staff reporter · 17 November 2026</div>
<p>The council voted on Tuesday evening to build the line that will link the harbour to the northern districts.
Work is to start in the spring and to last four years, with the first trams running on the southern half two years
earlier.</p>
<p>Supporters called the vote overdue. The line was first proposed in 2016 and has been redrawn three times since,
each time to spare a street its trees or a square its market.</p>
<iframe class="slot" src="https://securepubads.g.doubleclick.net/gampad/adx?slot=inline" width="300" height="250" style="border: 0; margin: 8px 0;"></iframe>
<p>Opponents say the cost, now put at 480 million, will keep rising. The mayor answered that the city could not
afford another decade of buses stuck in the same traffic as the cars they were meant to replace.</p>
<p>The first works will close the harbour road at night from March.</p>
</article>
<aside>
<div class="sponsored"><b>Sponsored</b>Ten gadgets every commuter needs this winter</div>
<div class="sponsored"><b>Sponsored</b>The savings account the banks keep quiet about</div>
</aside>
</main>
<div id="veil" hidden></div>
<div id="consent" role="dialog" aria-modal="true" hidden>
<h2>We value your privacy</h2>
We and our 214 partners use cookies and similar technologies to store and read information on your device, to show
you personalised advertising and to measure its audience.
<div><button>Accept all</button><button>Reject all</button><button>Manage preferences</button></div>
</div>
<div id="cookie-bar" hidden>We use cookies to give you the best experience. <a href="#">Find out more</a> · <a href="#" role="button">OK, I agree</a></div>
<script src="https://www.google-analytics.com/analytics.js" async></script>
<script>
// (as a consent platform does: its boxes appear once the page has loaded)
window.addEventListener('load', function () {
for (const id of ['veil', 'consent', 'cookie-bar']) document.getElementById(id).hidden = false;
});
</script>
</body></html>