# Screenshot & PDF API (`henryklimes/screenshot-pdf`) Actor

Use this when you need bulk website screenshots or PDFs of any URL as PNG, JPEG, WebP or PDF. Supports full-page, element and mobile viewports, plus cookie-banner hiding. Input a list of URLs. Failed captures are not billed. $2 per 1,000 successful captures. Not a text or product scraper.

- **URL**: https://apify.com/henryklimes/screenshot-pdf.md
- **Developed by:** [Jindrich Klimes](https://apify.com/henryklimes) (community)
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$2.00 / 1,000 successful captures

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

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

## Screenshot & PDF API

**High-performance screenshot and PDF generation for any website. Capture pages as PNG, JPEG, WebP, or PDF with full customization.**

The Screenshot & PDF API Actor provides a reliable, fast way to capture website screenshots and generate PDFs at scale. Perfect for website monitoring, content archiving, report generation, social media previews, QA testing, and AI agents that need to "see" web pages.

### Why This Actor?

✅ **Fast & Reliable** - Built on Playwright with proper error handling and robust resource management\
✅ **Cost-Optimized** - Efficient browser reuse, smart resource blocking, and high concurrency support\
✅ **Feature-Rich** - Full viewport control, element selection, wait strategies, dark mode, custom CSS/JS\
✅ **Clean Output** - Auto-hide cookie banners, trigger lazy loading, capture exactly what you need\
✅ **Flexible Formats** - PNG, JPEG, WebP screenshots + full PDF generation\
✅ **AI-Friendly** - Structured output with metadata, public file URLs, detailed error reporting

### Features

- **Multiple formats**: PNG, JPEG, WebP, and PDF in a single run
- **Device presets**: Desktop (1920×1080), Tablet (768×1024), Mobile (375×667), or custom viewport
- **Full page or viewport**: Capture entire scrollable page or just visible area
- **Element selection**: Capture a specific element by CSS selector
- **Smart waiting**: Wait for load event, network idle, fixed delay, or specific CSS selector
- **Cookie banner removal**: Best-effort hiding of common consent dialogs
- **Dark mode support**: Emulate `prefers-color-scheme: dark`
- **Custom CSS/JS injection**: Modify page appearance or behavior before capture
- **Lazy loading**: Auto-scroll to trigger lazy-loaded images
- **PDF customization**: A4/Letter/Legal formats, landscape, margins, background graphics
- **Quality control**: Adjustable JPEG/WebP quality (1-100)
- **Concurrent processing**: Configure max concurrency for speed vs. resources
- **Proxy support**: Optional Apify Proxy configuration
- **Detailed metadata**: Page title, dimensions, file size, HTTP status, timestamps

### Input

```json
{
  "urls": [
    "https://example.com",
    "https://en.wikipedia.org/wiki/Web_scraping"
  ],
  "outputFormats": ["png", "pdf"],
  "viewportPreset": "desktop",
  "fullPage": true,
  "waitStrategy": "load",
  "hideCookieBanners": true,
  "darkMode": false,
  "scrollToTriggerLazyLoad": false,
  "imageQuality": 90,
  "pdfFormat": "A4",
  "pdfLandscape": false,
  "pdfPrintBackground": true,
  "timeout": 30,
  "maxConcurrency": 3
}
```

#### Input Parameters

| Parameter | Type | Required | Default | Description |
|-----------|------|----------|---------|-------------|
| `urls` | Array | ✅ Yes | - | List of URLs to capture |
| `outputFormats` | Array | ✅ Yes | `["png"]` | Capture formats: `png`, `jpeg`, `webp`, `pdf` |
| `viewportPreset` | String | No | `desktop` | Device preset: `desktop` (1920×1080), `tablet` (768×1024), `mobile` (375×667), `custom` |
| `viewportWidth` | Integer | No | 1920 | Custom viewport width (only used if preset is `custom`) |
| `viewportHeight` | Integer | No | 1080 | Custom viewport height (only used if preset is `custom`) |
| `fullPage` | Boolean | No | `true` | Capture entire scrollable page (true) or just viewport (false) |
| `waitStrategy` | String | No | `load` | When to capture: `load`, `networkidle`, `delay`, `selector` |
| `waitDelay` | Integer | No | 2000 | Fixed delay in ms (used when waitStrategy is `delay`) |
| `waitSelector` | String | No | - | CSS selector to wait for (used when waitStrategy is `selector`) |
| `captureSelector` | String | No | - | CSS selector to capture only a specific element |
| `hideCookieBanners` | Boolean | No | `true` | Attempt to hide common cookie consent banners |
| `darkMode` | Boolean | No | `false` | Emulate dark mode (`prefers-color-scheme: dark`) |
| `customCss` | String | No | - | Inject custom CSS before capture |
| `customJavaScript` | String | No | - | Execute custom JavaScript before capture |
| `scrollToTriggerLazyLoad` | Boolean | No | `false` | Slowly scroll down to trigger lazy-loaded images |
| `imageQuality` | Integer | No | 90 | JPEG/WebP quality (1-100, PNG ignores this) |
| `pdfFormat` | String | No | `A4` | PDF page size: `A4`, `Letter`, `Legal` |
| `pdfLandscape` | Boolean | No | `false` | Use landscape orientation for PDFs |
| `pdfPrintBackground` | Boolean | No | `true` | Include background graphics in PDFs |
| `pdfMargin` | String | No | - | PDF margins (e.g., `10mm`, `0.5in`) |
| `timeout` | Integer | No | 30 | Timeout per URL in seconds (5-120) |
| `maxConcurrency` | Integer | No | 3 | Max concurrent browser pages (1-10) |
| `proxyConfiguration` | Object | No | - | Apify Proxy config (leave empty for no proxy) |

### Output

Each URL produces one dataset row per output format:

```json
{
  "url": "https://example.com",
  "final_url": "https://example.com/",
  "status": "ok",
  "http_status": 200,
  "format": "png",
  "file_key": "example-com-1699882920000.png",
  "file_url": "https://api.apify.com/v2/key-value-stores/abc123/records/example-com-1699882920000.png",
  "width": 1920,
  "height": 3840,
  "file_size_bytes": 524288,
  "page_title": "Example Domain",
  "captured_at": "2026-11-13T15:22:00.000Z",
  "error_message": null
}
```

#### Output Fields

| Field | Type | Description |
|-------|------|-------------|
| `url` | String | Original URL requested |
| `final_url` | String | Final URL after redirects |
| `status` | String | Capture status: `ok` or `error` |
| `http_status` | Integer | HTTP response status code (null if unavailable) |
| `format` | String | File format: `png`, `jpeg`, `webp`, or `pdf` |
| `file_key` | String | Key in the key-value store (null on error) |
| `file_url` | String | Public URL to download the file (null on error) |
| `width` | Integer | Image width in pixels (null for PDFs or on error) |
| `height` | Integer | Image height in pixels (null for PDFs or on error) |
| `file_size_bytes` | Integer | File size in bytes (null on error) |
| `page_title` | String | Page title from HTML `<title>` tag (null on error) |
| `captured_at` | String | ISO 8601 timestamp when captured |
| `error_message` | String | Error details if status is `error` (null otherwise) |

#### Accessing Captured Files

Files are stored in the Actor run's default key-value store. Download them:

1. **Via dataset URLs**: Each row's `file_url` field contains a direct download link
2. **Via Apify API**: `GET https://api.apify.com/v2/key-value-stores/{storeId}/records/{file_key}`
3. **Via Apify Console**: View the run's key-value store tab

Files are publicly accessible for the lifetime of the run's storage (default: 7 days for free accounts, configurable for paid).

### Use Cases & Recipes

#### 📸 Website Monitoring

Track visual changes to detect unauthorized modifications, monitor uptime, or analyze competitor strategies.

**Recipe:**

```json
{
  "urls": ["https://competitor.com/pricing", "https://mysite.com/landing"],
  "outputFormats": ["png"],
  "viewportPreset": "desktop",
  "fullPage": true,
  "waitStrategy": "load"
}
```

**Schedule**: Run daily or hourly via Apify Schedules. Compare screenshots with previous runs to detect changes. Store results in named KV stores for long-term retention.

#### 🎨 Open Graph & Social Preview Images

Generate accurate social media preview images by capturing pages at the standard Open Graph dimensions (1200×630).

**Recipe:**

```json
{
  "urls": ["https://blog.example.com/article-1"],
  "outputFormats": ["png"],
  "viewportPreset": "custom",
  "viewportWidth": 1200,
  "viewportHeight": 630,
  "fullPage": false,
  "hideCookieBanners": true
}
```

**Integration**: Pipe to image processing APIs, upload to CDN, or validate Open Graph tags before publishing.

#### 📦 Archiving & Compliance PDFs

Create permanent PDF records of web pages for legal compliance, auditing, or historical documentation.

**Recipe:**

```json
{
  "urls": ["https://docs.example.com/terms", "https://contracts.example.com/agreement-123"],
  "outputFormats": ["pdf"],
  "pdfFormat": "Letter",
  "pdfPrintBackground": true,
  "pdfMargin": "0.5in",
  "waitStrategy": "networkidle"
}
```

**Best practices**: Enable `pdfPrintBackground` for complete visual fidelity. Use Letter/Legal formats for US compliance. Store in named KV stores with long retention periods.

#### 🧪 QA Visual Regression Testing

Automate visual testing by comparing screenshots across deployments, browsers, or time periods.

**Recipe:**

```json
{
  "urls": ["https://staging.example.com/checkout", "https://production.example.com/checkout"],
  "outputFormats": ["png"],
  "viewportPreset": "mobile",
  "fullPage": true,
  "waitStrategy": "networkidle",
  "hideCookieBanners": true
}
```

**Workflow**: Capture both staging and production, use image diff tools (e.g., Pixelmatch) to detect visual regressions. Integrate with CI/CD pipelines via webhooks.

### Integrations

The Actor outputs data to Apify's dataset storage, which integrates with:

- **API** - Fetch results via Apify's REST API
- **Webhooks** - Get notified when runs complete, then download files
- **Google Sheets** - Export metadata to spreadsheets
- **Make** - Build workflows with 1000+ apps
- **Zapier** - Connect to 5000+ apps
- **n8n** - Self-hosted workflow automation
- **Direct download** - Use `file_url` in dataset rows to download files programmatically

### Examples

#### Basic Screenshot

Capture example.com as PNG:

```json
{
  "urls": ["https://example.com"],
  "outputFormats": ["png"]
}
```

#### Mobile Screenshot with Lazy Loading

```json
{
  "urls": ["https://news.ycombinator.com"],
  "outputFormats": ["png"],
  "viewportPreset": "mobile",
  "scrollToTriggerLazyLoad": true,
  "waitStrategy": "networkidle"
}
```

#### Dark Mode PDF

```json
{
  "urls": ["https://docs.github.com"],
  "outputFormats": ["pdf"],
  "darkMode": true,
  "pdfFormat": "Letter",
  "pdfPrintBackground": true
}
```

#### Capture Specific Element

Capture only the main article:

```json
{
  "urls": ["https://en.wikipedia.org/wiki/Web_scraping"],
  "outputFormats": ["png"],
  "captureSelector": "#mw-content-text",
  "fullPage": false
}
```

#### Custom CSS Injection

Remove ads and adjust styling:

```json
{
  "urls": ["https://example.com"],
  "outputFormats": ["png"],
  "customCss": ".ad, .sidebar { display: none !important; } body { font-size: 18px; }"
}
```

#### High-Resolution Multiple Formats

Capture as PNG and PDF with custom viewport:

```json
{
  "urls": ["https://example.com"],
  "outputFormats": ["png", "pdf"],
  "viewportPreset": "custom",
  "viewportWidth": 2560,
  "viewportHeight": 1440,
  "imageQuality": 95
}
```

### Ready-made example tasks

Open one, check the prefilled input, and run it in one click:

- [Convert a list of URLs to PDF in bulk](https://apify.com/henryklimes/screenshot-pdf/examples/bulk-url-to-pdf)
- [Take full-page screenshots of websites](https://apify.com/henryklimes/screenshot-pdf/examples/full-page-website-screenshots)
- [Capture mobile screenshots of websites](https://apify.com/henryklimes/screenshot-pdf/examples/mobile-website-screenshots)

### Pricing

This Actor uses **pay-per-event** pricing at **$0.002 per successful capture** ($2.00 per 1,000 captures).

#### How Captures Are Counted

**One `capture` event is charged per successful file generated:**

- ✅ 1 URL + 1 format (PNG) = **1 capture** = $0.002
- ✅ 1 URL + 2 formats (PNG + PDF) = **2 captures** = $0.004
- ✅ 100 URLs + 1 format = **100 captures** = $0.20
- ❌ Failed captures = **0 captures** (free)

**Important**: Each output format counts as one capture. If you request 3 formats (PNG, JPEG, PDF) for 1 URL, you'll be charged for 3 captures.

**Example scenarios**:

- Website monitoring (1,000 PNGs daily) = 1,000 captures = **$2.00/day**
- Social previews (500 URLs, PNG + WebP) = 1,000 captures = **$2.00/batch**
- PDF archiving (200 contracts) = 200 captures = **$0.40/batch**

Use `maxConcurrency` and `blockResources` options to optimize speed without affecting cost.

### Performance & Limitations

#### Performance

- **Speed**: ~2-4 seconds per URL (desktop viewport, viewport PNG with resource blocking)
- **Memory**: Optimized browser reuse reduces overhead
- **Recommended concurrency**: 5-8 for 2048 MB, 3-5 for 1536 MB

#### Limitations

- **JavaScript required**: Only works with JavaScript-enabled content (uses real browser)
- **Authentication**: No built-in login flow (use custom JavaScript or cookies)
- **Dynamic content**: Some pages with complex SPAs may need custom wait strategies
- **File retention**: Files stored in KV store follow Apify's retention policy (default: 7-30 days)

### FAQ

#### Why do some captures have cookie banners?

The Actor tries to hide common cookie consent dialogs, but new or custom banners may not be detected. Use `customCss` to hide specific elements:

```json
{
  "customCss": "#cookie-banner { display: none !important; }"
}
```

#### How do I capture pages that require login?

This Actor doesn't include authentication flows. Options:

1. Use `customJavaScript` to set cookies/localStorage before capture
2. Capture pages with public access tokens in the URL
3. Use a custom Actor that handles your specific auth flow

#### Can I capture localhost or internal URLs?

No. Apify Actors run in the cloud and cannot access local networks. Use the Apify CLI to test locally, or deploy your internal pages with public access.

#### Why is my PDF cut off or missing content?

Try these fixes:

- Set `pdfPrintBackground: true` to include background images
- Increase `timeout` to allow more time for content to load
- Use `waitStrategy: "networkidle"` to wait for all resources
- Use `scrollToTriggerLazyLoad: true` for lazy-loaded content

#### What's the difference between PNG and JPEG?

- **PNG**: Lossless, larger files, supports transparency, best for text-heavy pages
- **JPEG**: Lossy, smaller files, no transparency, best for photo-heavy pages
- **WebP**: Modern format, smaller than JPEG, lossy or lossless, best browser support

Use PNG for documents/dashboards, JPEG for content-heavy sites, WebP for modern workflows.

#### How long are captured files stored?

Files are stored in the Actor run's key-value store, which follows Apify's data retention policy:

- **Free accounts**: 7 days
- **Paid accounts**: 30+ days (configurable)

Download files immediately or use Apify's named key-value stores for longer retention.

#### Can I capture sites behind Cloudflare or bot detection?

Basic Cloudflare challenges should work. For advanced bot detection:

- Enable `proxyConfiguration` with Apify residential proxies
- Use `waitStrategy: "delay"` with higher delays
- Inject custom headers via `customJavaScript`

If you encounter persistent issues, contact support.

#### What is resource blocking and should I use it?

By default, the Actor blocks fonts and video/audio resources (`blockResources: true`) to speed up page loads without affecting visual output. This reduces network overhead and speeds up captures by 20-40% on media-heavy sites.

**What's blocked**: Web fonts, video elements, audio elements\
**What's kept**: Images, stylesheets, scripts, iframes

Turn it off (`blockResources: false`) if:

- You need exact font rendering for typography-sensitive captures
- The page requires media elements to render correctly

### Support

- **Issues**: Report bugs or request features via the Apify Store issues tab for this Actor
- **Documentation**: [Apify Actors documentation](https://docs.apify.com/actors)

### License

This Actor is proprietary software operated by Cleanrows. Usage is subject to Apify's Terms of Service and Cleanrows' usage policies.

***

**More Cleanrows Actors**: Check out our [ATS Jobs Feed Actor](https://apify.com/henryklimes/ats-jobs-feed) for recruiting intelligence and lead generation from hiring data.

# Actor input Schema

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

List of URLs to capture as screenshots or PDFs

## `outputFormats` (type: `array`):

Capture formats (at least one required)

## `viewportPreset` (type: `string`):

Device viewport preset (use this or custom width/height)

## `viewportWidth` (type: `integer`):

Custom viewport width in pixels (only used if preset is 'custom')

## `viewportHeight` (type: `integer`):

Custom viewport height in pixels (only used if preset is 'custom')

## `fullPage` (type: `boolean`):

Capture the entire page (scroll down) or just viewport

## `waitStrategy` (type: `string`):

When to take the screenshot

## `waitDelay` (type: `integer`):

Fixed delay in milliseconds before capture (used when waitStrategy is 'delay')

## `waitSelector` (type: `string`):

CSS selector to wait for before capture (used when waitStrategy is 'selector')

## `captureSelector` (type: `string`):

CSS selector to capture only a specific element (instead of full page)

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

Best-effort attempt to hide common cookie consent banners

## `darkMode` (type: `boolean`):

Emulate dark mode (prefers-color-scheme: dark)

## `customCss` (type: `string`):

Inject custom CSS before capture

## `customJavaScript` (type: `string`):

Execute custom JavaScript before capture (function body)

## `scrollToTriggerLazyLoad` (type: `boolean`):

Slowly scroll down the page to trigger lazy-loaded images

## `blockResources` (type: `boolean`):

Block fonts and video/audio to speed up capture (keeps images)

## `imageQuality` (type: `integer`):

JPEG/WebP quality (1-100, PNG ignores this)

## `pdfFormat` (type: `string`):

PDF page size (only used when PDF is in outputFormats)

## `pdfLandscape` (type: `boolean`):

Use landscape orientation for PDFs

## `pdfPrintBackground` (type: `boolean`):

Include background graphics in PDFs

## `pdfMargin` (type: `string`):

PDF margin (e.g., '10mm', '0.5in')

## `timeout` (type: `integer`):

Maximum time to wait for each URL before failing

## `maxConcurrency` (type: `integer`):

Maximum number of concurrent browser pages

## `proxyConfiguration` (type: `object`):

Apify Proxy configuration (leave empty for no proxy)

## Actor input object example

```json
{
  "urls": [
    "https://example.com",
    "https://en.wikipedia.org/wiki/Web_scraping"
  ],
  "outputFormats": [
    "png"
  ],
  "viewportPreset": "desktop",
  "viewportWidth": 1920,
  "viewportHeight": 1080,
  "fullPage": true,
  "waitStrategy": "load",
  "waitDelay": 2000,
  "waitSelector": ".main-content",
  "captureSelector": "#main-article",
  "hideCookieBanners": true,
  "darkMode": false,
  "scrollToTriggerLazyLoad": false,
  "blockResources": true,
  "imageQuality": 90,
  "pdfFormat": "A4",
  "pdfLandscape": false,
  "pdfPrintBackground": true,
  "pdfMargin": "10mm",
  "timeout": 30,
  "maxConcurrency": 5
}
```

# Actor output Schema

## `captureResults` (type: `string`):

Metadata for each capture including status, URLs, dimensions, and file size

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

All captured screenshots and PDFs stored in key-value store

# 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://example.com",
        "https://en.wikipedia.org/wiki/Web_scraping"
    ],
    "outputFormats": [
        "png"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("henryklimes/screenshot-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://example.com",
        "https://en.wikipedia.org/wiki/Web_scraping",
    ],
    "outputFormats": ["png"],
}

# Run the Actor and wait for it to finish
run = client.actor("henryklimes/screenshot-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://example.com",
    "https://en.wikipedia.org/wiki/Web_scraping"
  ],
  "outputFormats": [
    "png"
  ]
}' |
apify call henryklimes/screenshot-pdf --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,henryklimes/screenshot-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/TfeNxU0f3ViiUYbaa/builds/iwd5BJmSZLaMKE6f7/openapi.json
