# URL to PDF: Save Web Pages as PDF, A4 or Letter (`ucchiii/url-to-pdf`) Actor

Save public web pages as PDF files with a real Chrome browser: A4, Letter and more, portrait or landscape, margins, background colors, page numbers and cookie banners hidden. Each PDF gets a download link. Empty input runs a free demo.

- **URL**: https://apify.com/ucchiii/url-to-pdf.md
- **Developed by:** [Actor Factory](https://apify.com/ucchiii) (community)
- **Categories:** Developer tools, Automation
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $4.55 / 1,000 rendered pdfs

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

**URL to PDF: save public web pages as PDF files, rendered by a real Chrome browser.**

Paste page URLs, pick the paper size, press **Start**: each page is opened in headless Chromium and printed to a PDF, like *Save as PDF* in your browser — but for up to 50 pages at once, with the same settings every time. Every PDF is stored in the run's key-value store and gets a download link in the results table.

**Try it free:** leave the URL list empty and press **Start** — a built-in sample page is saved as an A4 PDF with page numbers (not charged, the row carries `_demo: true`).

### What you get

| url | status | title | paperFormat | landscape | pages | bytes | fileUrl |
|---|---|---|---|---|---|---|---|
| https://www.python.org/about/ | 200 | About Python | A4 | false | 3 | 412,330 | https://api.apify.com/v2/key-value-stores/…/records/pdf-001-www.python.org-….pdf |
| https://example.com/report | 200 | Q3 report | Letter | true | 7 | 1,035,104 | https://api.apify.com/v2/key-value-stores/…/records/pdf-002-example.com-….pdf |

- **Paper and layout:** A4, US Letter, US Legal, A3 or A5; portrait or landscape; margins in millimetres; scale 0.1 to 2.
- **Looks like the page:** background colors and images are printed by default; choose the page's print stylesheet (default, like a browser's Print dialog) or its screen look.
- **Clean pages:** common cookie banners are hidden with CSS (nothing is clicked or accepted); optionally block common ad and tracking domains.
- **Late content:** wait for `load`, `domcontentloaded` or `networkidle`, plus an extra delay of up to 10 seconds for charts and animations.
- **Page numbers:** optional "Page 1 of N" footer.

### How to use

1. **Page URLs**: public `http(s)` pages, one per line (up to 50).
2. Choose **Paper size**, **Landscape**, margins, **Print backgrounds** and other options.
3. Press **Start** and open the PDFs from the `fileUrl` column, or download them from the run's key-value store.

```json
{
  "urls": ["https://www.python.org/about/", "https://example.com/pricing"],
  "paperFormat": "Letter",
  "landscape": false,
  "marginTopMm": 10,
  "marginBottomMm": 15,
  "printBackground": true,
  "pageNumbers": true
}
```

### Output fields

- `url`, `finalUrl` (after redirects), `status` (HTTP status of the page), `title`
- `paperFormat`, `landscape`, `pages`, `bytes`
- `fileUrl` — signed download link to the PDF, `key` — its name in the key-value store
- `error` — `invalid_url`, `unsupported_domain`, `blocked_private_address`, `timeout`, `navigation_failed`, `http_404` and other `http_4xx/5xx`, `render_failed`, `pdf_too_large`, `storage_failed`; `null` on success
- **STATS** record: URLs, PDFs saved, failures, PDFs charged and whether the run stopped at the maximum charge

### Limits (cannot be raised by input)

- Up to 50 URLs per run; 45 seconds to load each page and 60 seconds to print it; PDFs up to 30 MB each
- At most 3 pages at a time and 2 at a time from the same site; links are not followed (no crawling)
- No login, cookies or custom headers: only pages anyone can open. Social networks (Facebook, Instagram, X/Twitter, TikTok, LinkedIn, Threads) are refused
- Internal network addresses (localhost, private ranges, 169.254.169.254) are blocked, including redirects and every image, script or font the page loads
- Want to turn your own HTML into PDF instead of a URL? Use the HTML to PDF API from the same developer.

### Pricing

Pay per event: **$0.0065 per rendered PDF**, no start fee. Only PDFs that were saved are charged: failed, timed-out, blocked and unsupported URLs and the demo are free. Set a maximum charge per run and the Actor stops rendering before it is exceeded.
Store discounts apply automatically: BRONZE −10%, SILVER −20%, GOLD −30%.
On the Apify Free plan, the $5 of monthly platform credit covers about 760 PDFs a month.

### FAQ

**Why does my PDF look different from the screen?** By default the page's print stylesheet is used, like Chrome's Print dialog — many sites hide menus and ads for print. Set **CSS media type** to `screen` to keep the on-screen look.

**The page is cut off or too wide.** Try **Landscape**, or a **Scale** of 0.8.

**Charts or images are missing.** Use **Wait until** `networkidle` and an **Extra delay** of 1,000–3,000 ms.

**Is the PDF text searchable?** Yes. Chromium prints real text, so you can search and copy it.

**Who may I convert?** Only pages you are allowed to copy. You are responsible for the site's terms and copyright.

### More tools from the same developer

- [HTML to PDF API](https://apify.com/ucchiii/html-to-pdf) — HTML strings or public URLs to PDF: A4 / Letter, margins, header, footer, page numbers
- [Website Screenshot](https://apify.com/ucchiii/website-screenshot) — screenshots and PDFs of web pages: full page, mobile, element, no cookie banners
- [PDF to Text Converter](https://apify.com/ucchiii/pdf-to-text) — plain text per page from public PDF URLs, plus one .txt file per PDF
- [HTML to Markdown Converter for LLM and RAG](https://apify.com/ucchiii/html-to-markdown) — clean Markdown from URLs, raw HTML or datasets for LLM and RAG

# Actor input Schema

## `urls` (type: `array`):

Public http(s) web pages to save as PDF, one PDF each, up to 50 per run. No login, cookies or custom headers. Social networks (Facebook, Instagram, X/Twitter, TikTok, LinkedIn, Threads) and internal addresses are refused. Leave empty for a free demo (a built-in sample page, not charged).

## `paperFormat` (type: `string`):

Paper size of every page: 'A4' (default), 'Letter', 'Legal', 'A3' or 'A5'.

## `landscape` (type: `boolean`):

Print pages sideways (wide instead of tall). Default off (portrait).

## `marginTopMm` (type: `integer`):

Top margin in millimetres, 0 to 50 (default 10).

## `marginRightMm` (type: `integer`):

Right margin in millimetres, 0 to 50 (default 10).

## `marginBottomMm` (type: `integer`):

Bottom margin in millimetres, 0 to 50 (default 10). With page numbers on, at least 15 is used so the numbers do not overlap the text.

## `marginLeftMm` (type: `integer`):

Left margin in millimetres, 0 to 50 (default 10).

## `printBackground` (type: `boolean`):

Print background colors and background images. On by default; turn off for plain black-on-white output that saves ink.

## `pageNumbers` (type: `boolean`):

Print 'Page 1 of 3' centered at the bottom of every page. Default off.

## `mediaType` (type: `string`):

Which CSS rules apply: 'print' (default) uses @media print rules like a browser's Print dialog; 'screen' keeps the on-screen look.

## `scale` (type: `number`):

Zoom of the page content, 0.1 to 2 (default 1). Use 0.8 to fit wide pages onto the paper.

## `waitUntil` (type: `string`):

When the page counts as loaded: 'load' (default), 'domcontentloaded' (fastest) or 'networkidle' (slowest, for late content). Each item has a 45 second limit.

## `delayMs` (type: `integer`):

Wait this long after loading before printing, 0 to 10000 ms. Useful for charts and animations.

## `hideCookieBanners` (type: `boolean`):

Hide common consent pop-ups (OneTrust, Cookiebot, Didomi, Quantcast, TrustArc, Usercentrics, CookieYes, Osano and generic cookie banners) with CSS so they do not cover the PDF. On by default. Nothing is clicked or accepted.

## `blockAds` (type: `boolean`):

Block requests to a small built-in list of common ad and tracking domains. Not a complete filter.

## Actor input object example

```json
{
  "urls": [
    "https://www.python.org/about/"
  ],
  "paperFormat": "A4",
  "landscape": false,
  "marginTopMm": 10,
  "marginRightMm": 10,
  "marginBottomMm": 10,
  "marginLeftMm": 10,
  "printBackground": true,
  "pageNumbers": false,
  "mediaType": "print",
  "scale": 1,
  "waitUntil": "load",
  "delayMs": 0,
  "hideCookieBanners": true,
  "blockAds": false
}
```

# Actor output Schema

## `results` (type: `string`):

One item per URL: final URL, HTTP status, title, paper size, pages, bytes, fileUrl (signed link to the PDF) and error.

## `files` (type: `string`):

The PDF files in the run's key-value store.

## `stats` (type: `string`):

Record STATS: URLs, PDFs saved, failures, PDFs charged and whether the run stopped at the maximum charge.

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "urls": [
        "https://www.python.org/about/"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("ucchiii/url-to-pdf").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = { "urls": ["https://www.python.org/about/"] }

# Run the Actor and wait for it to finish
run = client.actor("ucchiii/url-to-pdf").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "urls": [
    "https://www.python.org/about/"
  ]
}' |
apify call ucchiii/url-to-pdf --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,ucchiii/url-to-pdf"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/hvaqE6I6WDJCk8QlD/builds/ztWdas2ifjOKqPp1A/openapi.json
