Convert a web page to a clean PDF, without ads or cookie banners
Convert a web page to PDF without ads, consent dialogs or a sticky header stamped on every page break. Research exports, client reports, legal copies and reading lists all need the content, not the browser tab around it. The PDF API blocks the third-party noise before the page renders and lets you hide the rest with one CSS rule.
Browser-saved PDFs carry the ads, banners and sticky headers along
Web pages are built to be scrolled, not paginated. Print one as it is and the ad slots leave holes in the text, the cookie banner covers the first paragraph, the fixed navigation repeats at the top of every sheet, and a wide layout gets squeezed into an unreadable column.
The usual fixes are manual or brittle. Reader mode and print dialogs work for one page at a time, not for a pipeline. HTML-to-PDF converters that skip the browser skip the site’s CSS too, so the result looks nothing like the article. A self-hosted headless Chrome prints faithfully, including every popup it was served.
Microlink renders the page in a real browser with adblock enabled by default, so ad, tracker and cookie consent requests are blocked before they run. PDFs use the print media type, so the site’s print stylesheet applies, and styles removes whatever is left. Switch mediaType to screen when the print stylesheet strips too much.
How to convert a web page to PDF without ads
Start with the defaults, because they already block most of the noise. Add a CSS rule for site-specific chrome, then pick print or screen styles depending on what the site ships. The PDF page preparation guide walks through each control.
import createClient from 'microlink.io'
const microlink = createClient({
apiKey: process.env.MICROLINK_API_KEY
})
const { url } = await microlink.pdf('https://example.com/article')No options needed: adblock stops ads, trackers and third-party consent services, and the print media type applies the site’s own print stylesheet. url points to the hosted A4 document.
import createClient from 'microlink.io'
const microlink = createClient({
apiKey: process.env.MICROLINK_API_KEY
})
const { url } = await microlink.pdf('https://example.com/article', {
styles: [
'header, .navbar, .cookie-banner, .newsletter { display: none !important }',
'main { max-width: 900px !important; margin: 0 auto !important }'
]
})Injected CSS removes the navigation that would repeat on each page and gives long text a readable measure. styles accepts inline rules or the absolute URL of a stylesheet.
curl 'https://api.microlink.io/?url=https%3A%2F%2Fexample.com%2Farticle&pdf=true&meta=false&mediaType=screen&styles=header%2C+.cookie-banner+%7B+display%3A+none+%21important+%7D'mediaType=screen keeps the on-screen design when the print stylesheet removes images or changes fonts. Try the result first with the website to PDF converter before wiring the URL into your code.
- adblock Blocks third-party ad, tracker and cookie consent requests. On by default on every plan.
- styles Inline CSS or an absolute stylesheet URL injected before printing.
- mediaType print (the default for PDFs) or screen.
- click Clicks one selector or several in order, to dismiss a first-party banner or expand a section before printing.
- javascript Set to false for static pages to skip client-side widgets and reduce rendering work. Default true.
Think in page state: block the noise, wait for the content, hide the chrome, then print. The same options drive screenshots without cookie banners or ads, so a clean capture recipe carries over. Reach for the function parameter only when CSS and clicks are not enough.
Why a real browser with adblock makes a cleaner PDF
Rendering the real page and subtracting the noise is more faithful than converting raw HTML, and blocking a request is more reliable than hiding its result. The adblock feature runs inside the rendering browser on every plan.
Turn it off with adblock: false only when the PDF must show the page exactly as a first-time visitor sees it.
A narrower max-width on the main column is the single most effective rule for long articles: fewer awkward page breaks, easier reading. It is the base of the article archiving recipe.
When not to: if you need the consent flow or the ads in the document, for an audit or a compliance record, disable adblock and skip the CSS. If you only need the text, clean Markdown is lighter than a PDF.
FAQ
Why does my PDF still show a cookie banner?
Should I use print or screen styles when converting a page to PDF?
How do I remove the sticky header that repeats on every PDF page?
Do I need a paid plan to convert a web page to PDF without ads?
Does disabling JavaScript produce a cleaner PDF?
Solve the next problem with the same API
Archive web articles as PDF
Paper size, margins and orientation
PDFs of JavaScript-rendered pages
PDF download links and previews
Screenshots without cookie banners or ads
Clean Markdown, no boilerplate
Ready for clean PDFs?
Ads and banners gone by default, chrome removed with one rule. Start on the free tier and print your first clean document today.