Skip to content
PDF API · Use case

Save web articles and documentation as PDF for your archive

Save a web article as PDF with one API call and keep a copy that survives edits, paywalls and dead links. Research teams, legal and compliance desks, newsroom libraries and read-it-later apps all need the same thing: a document that reads offline, can be searched and attaches to a ticket. The PDF API prints the article the way its print stylesheet intends, with the noise removed and only the pages you need.

The problem

Bookmarks rot, and a screenshot of an article cannot be searched

A bookmarked article can be paywalled, edited or deleted a year later, and the link in your notes quietly turns into a 404. What you cited is no longer what the page says, and there is no copy to check against.

The common workarounds each lose something. A screenshot preserves pixels but not text, so it cannot be searched or quoted. Copy-pasting into a document drops the source, the images and the formatting. Printing by hand from the browser works for one page and drags the ads, the cookie banner and the comment section along.

Printing to PDF from a real browser keeps the text selectable and the layout readable. Microlink renders the article with its print stylesheet, blocks ads and consent popups through adblock, lets you hide what remains with styles, and trims the document with pdf.pageRanges.

How it works

How to save a web article as PDF and store the file

A readable archive is a layout choice plus a retention choice. The layout comes from the request; the retention is your storage. The clean PDF recipe goes deeper on removing page chrome.

1 · Print a readable article
import createClient from 'microlink.io'

const microlink = createClient({
  apiKey: process.env.MICROLINK_API_KEY
})

const { url, size_pretty: size } = await microlink.pdf(
  'https://example.com/blog/long-read',
  {
    format: 'A4',
    margin: '1cm',
    styles: ['header, footer, aside { display: none !important }']
  }
)

A4 with a one-centimeter margin and the chrome hidden reads well on screen and on paper. The response gives you the hosted url plus the file size.

2 · Download and store it yourself
import createClient from 'microlink.io'

const microlink = createClient({
  apiKey: process.env.MICROLINK_API_KEY
})

import { writeFile } from 'node:fs/promises'

const { url } = await microlink.pdf('https://example.com/blog/long-read')
const response = await fetch(url)
await writeFile('archive/long-read.pdf', Buffer.from(await response.arrayBuffer()))

The hosted URL is for delivery, not for retention. Copy the file into storage you control, such as a bucket or a document store, under the retention policy your archive needs.

3 · The same request as a URL
curl 'https://api.microlink.io/?url=https%3A%2F%2Fexample.com%2Fblog%2Flong-read&pdf.format=A4&pdf.margin=1cm&pdf.pageRanges=1-10&meta=false'

pageRanges trims the comment sections and footers that run past the article. A range that falls outside the document fails with EPAGERANGE, so size it to the article instead of guessing high.

Parameters used
  • pdf.format A4 (the default) or Letter for archives that may be printed.
  • pdf.margin Whitespace around the text. Default 0.35cm; 1cm is a comfortable reading margin.
  • pdf.pageRanges Keeps only the pages that contain the article, for example 1-10.
  • styles Hides navigation, sidebars, comments and related-post widgets with injected CSS.
  • mediaType print by default for PDFs; screen when the print stylesheet drops images you want to keep.
  • ttl Keeps the response cached from 1 minute to 31 days while your job copies the file. Pro plans.

Leave meta at its default to get the page’s title, author, publisher and date in the same response; they make good filenames and index entries for the archive.

Why it works

Why PDF is the right format to archive web pages

The archive has to be readable in ten years and findable next week. A PDF printed from a real browser render gives you both.

01 · Text stays text
Searchable, quotable, selectable.
A browser-printed PDF keeps the article text as text rather than pixels. Full-text search in your archive works, and quotes copy cleanly, unlike an image capture of the same page.

For the raw content instead of a document, the Markdown API returns the same article as text you can index directly, and clean Markdown from any URL shows how to scope it to the article body.

02 · Print styles are made for this
Publishers already design the print version.
Many publications ship a print stylesheet that drops navigation and widens the text column. PDFs render with the print media type by default, so that design is applied without any option.

When a site’s print stylesheet is missing or too aggressive, switch mediaType to screen and trim with styles instead.

03 · You own the file
The API renders; your storage retains.
The response is cached for 24 hours by default and up to 31 days with ttl, which gives a job plenty of time to fetch the document and copy it into an archive you control, under the retention policy you need.

When not to: pages that require a login or sit behind bot protection need the headers or proxy parameters first, both on Pro plans. Paywalled content you are not licensed to keep should not be archived at all.

FAQ

Is the text in an archived PDF searchable?

Yes. The PDF is printed from the rendered page, so text stays text and you can search, select and quote it. Image-only content, such as text inside pictures, is not converted to text.

How do I keep an archived PDF permanently?

Fetch the hosted URL from the response and store the file in your own storage. The API response is cached for 24 hours by default, and up to 31 days with ttl on Pro plans, which is a delivery window, not a retention policy.

How do I remove comments and related posts from the article PDF?

Hide them with styles, for example .comments, .related { display: none !important }, or use pdf.pageRanges to keep only the pages that contain the article. The page preparation guide lists the other cleanup options.

Can I archive pages behind a login or a paywall as PDF?

Technically yes: forward your own session with x-api-header-* request headers on a Pro plan, as the private pages guide shows. Whether you may keep the content depends on the publisher’s terms, so archive only what you are licensed to store.

Can I save the title, author and date together with the PDF?

Yes. Leave meta enabled, which is the default, and the same response includes the normalized title, author, publisher, date and description next to the pdf field. Use them to name the file and to build the index of your archive. Set meta to false only when you want the fastest possible PDF-only request.
Related use cases

Solve the next problem with the same API

Clean PDFs without ads or banners

Get a document, not a browser tab: ads and consent popups blocked by default, sticky chrome removed with one CSS rule.

Paper size, margins and orientation

Print any URL on A4, Letter or custom paper, with per-side margins, landscape, scale and page ranges.

PDFs in bulk

Render thousands of documents from URLs in one job: parallel requests, server-side retries and per-document caching.

PDF download links and previews

Turn the API URL into the PDF itself for one-click download links and iframe previews, with no storage pipeline.

Clean Markdown, no boilerplate

Convert only the article body: one selector keeps navigation, ads and widgets out of the Markdown.

Markdown with metadata frontmatter

Get each page as Markdown with a YAML frontmatter block: title, author, date, word count and reading time.

Ready to archive the web as PDF?

Readable, searchable documents from any article, printed the way the publisher intended. Start on the free tier and build your first archive job today.