Save a web page as a PDF

Turn a live web page into a PDF with the pdf format of the Scrape API: pick a paper size and orientation, keep backgrounds, and clean the page before printing.

Updated

Wayfern makes PDFs with the Scrape API. Add pdf to formats, and the page is rendered in the same browser visit that produces the other formats. This guide shows the request, the paper options and how the page is prepared.

Request a PDF

curl -X POST https://api.wayfern.com/api/v1/scrape \
  -H "Authorization: Bearer $WAYFERN_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://example.com/terms",
    "formats": ["pdf"],
    "capture": {
      "pdfFormat": "Letter",
      "pdfLandscape": false
    }
  }'

The PDF is in data.pdf:

{
  "success": true,
  "data": {
    "pdf": {
      "url": "https://...",
      "urlExpiresAt": "2026-10-29T10:15:00.000Z",
      "key": "pdf/USER_ID/5d2c7e19-8a3b-4f60-9c14-2e7b0a9d6f31.pdf",
      "contentType": "application/pdf",
      "bytes": 183442,
      "expiresAt": "2026-11-05T10:00:00.000Z"
    },
    "metadata": { "title": "Terms of Service", "statusCode": 200 },
    "cached": false
  },
  "credits": 5
}

url is a signed link that stops working at urlExpiresAt. The file is kept for 7 days. Send its key to POST /api/v1/artifacts/link for a new link, at no cost.

What it costs

A scrape is 1 credit per page. The pdf format adds the output add-on of 4 credits, so a PDF costs 5 credits. The add-on is charged once per page, however many of screenshot, pdf and json you ask for. This request gets a PDF, an image and markdown for 5 credits:

{
  "url": "https://example.com/terms",
  "formats": ["markdown", "pdf", "screenshot"]
}

A scrape that fails is not charged.

Paper size and orientation

FieldValuesDefault
capture.pdfFormatLetter, Legal, Tabloid, A0 to A6A4
capture.pdfLandscapetrue, falsefalse

Backgrounds are always printed, so colored sections and background images stay in the PDF.

Screen styles, not print styles

Wayfern renders the PDF with the page’s screen styles. Many sites have print styles that hide navigation, images or whole sections. A PDF made with those styles often leaves out the content that you wanted to keep, so they are not used. To hide parts of the page, use hideSelectors.

Clean the page first

The capture object of a scrape takes the same preparation options as a screenshot, and they apply to the PDF:

  • blockCookieBanners (on by default) dismisses and hides consent banners.
  • blockAds blocks ad and tracker requests and hides ad slots.
  • hideSelectors, styles, click and scripts change the page before it is printed.
  • darkMode asks the page for its dark color scheme.
  • fullPage (on by default) scrolls through the page first, so that lazy images are loaded.
  • settleMs waits before the PDF is made, 250 ms by default.
{
  "url": "https://example.com/blog/release-notes",
  "formats": ["pdf"],
  "capture": {
    "pdfFormat": "A4",
    "blockAds": true,
    "hideSelectors": ["header.site-nav", "footer", "#newsletter"],
    "styles": "article { max-width: none !important; }"
  }
}

The page changes guide explains each option.

Asset blocking does not apply when a PDF is requested. Images and media load, so they appear in the file.

Limits

  • Rate limit: 60 requests a minute to POST /api/v1/scrape.
  • Timeout: 30 seconds by default, up to 120 seconds with timeout. A long page with many images may need more than the default.
  • A render is never served from the scrape cache. maxAge has no effect on a request with pdf or screenshot.
  • The failIfContains check and slices are Screenshot API options. A scrape rejects them with 400.

The MCP tool scrape_page also takes the pdf format, with A4 paper. Paper options are only on the REST API.

Every field is in the Scrape API reference, and all limits are on the limits page.