# Password-protect a PDF made from a web page

**Use case:** 

Create a PDF from a web page and lock it with a password. Give it a URL and set the PDF password input, and the PDF you get back asks for that password to open. Combine it with a watermark, or merge several pages first.

## Input

```json
{
  "sourceType": "url",
  "startUrls": [
    {
      "url": "https://en.wikipedia.org/wiki/Web_scraping"
    }
  ],
  "outputFormat": "pdf",
  "viewMode": "viewport",
  "viewportWidth": 1920,
  "viewportHeight": 1080,
  "scaleFactor": 2,
  "imageQuality": 80,
  "paperFormat": "A4",
  "printBackground": true,
  "mergePdfs": false,
  "pdfPassword": "<YOUR_SECRET>",
  "smartScroll": true,
  "scrollDelay": 500,
  "removeSelectors": [],
  "clickSelectors": [],
  "hideFixedElements": true
}
```

## Output

```json
{
  "url": {
    "label": "URL",
    "format": "string"
  },
  "outputFormat": {
    "label": "Format",
    "format": "string"
  },
  "viewMode": {
    "label": "Mode",
    "format": "string"
  },
  "fileName": {
    "label": "File",
    "format": "string"
  },
  "fileUrl": {
    "label": "Download",
    "format": "string"
  },
  "fileSize": {
    "label": "Size (bytes)",
    "format": "number"
  },
  "capturedAt": {
    "label": "Captured",
    "format": "string"
  }
}
```

## How it works

### 1. Sign up on Apify or log in

The HTML to PDF & URL to PDF API - Website Screenshots Actor is ready to run with the inputs already set for "Password-protect a PDF made from a web page". [Sign up or log in](https://console.apify.com/create-task-from-example/CHI8QySj9LLd7qfzY) and you'll land in Apify Console with a copy of this exact task.

### 2. Start the "Password-protect a PDF made from a web page" task

The HTML to PDF & URL to PDF API - Website Screenshots Actor will start running based on the input automatically. You can also change all the input fields, like source type, start urls, and more, to match your specific use case.

### 3. Receive the "Password-protect a PDF made from a web page" output

Monitor the progress in real time. You will be notified as soon as your dataset is complete and ready for review. Each result includes data such as URL, format, mode, and more.

### 4. Integrate into your workflow

The final output is delivered in JSON, CSV, or Excel format, ready to be plugged into your workflow. You can also [run the "Password-protect a PDF made from a web page" task via API](https://apify.com/autofacts/universal-web-printer.md).

## FAQ

### How do I set the password?

Fill in the PDF password input before you run. The PDF opens only with that password.

### Can I protect a PDF made from my own HTML?

Yes. Set the source type to HTML, paste your markup and set the same password input.

### Where do I get the file?

Each result has a download link. The files are also in the run’s key-value store, and you can fetch them through the Apify API.

### How much does it cost?

You pay per page rendered, plus a small extra for options such as watermarks, passwords or merging. Pages that fail to render are not charged. See the Pricing tab for current rates.

## About this Actor

This example demonstrates how to use [HTML to PDF & URL to PDF API - Website Screenshots](https://apify.com/autofacts/universal-web-printer.md) with a specific input configuration. Visit the [Actor detail page](https://apify.com/autofacts/universal-web-printer.md) to learn more, explore other use cases, and run it yourself.


## How to integrate an Actor?

This Task's input is already configured above. Use it as-is rather than inventing a new one.

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 full API examples (JavaScript, Python, CLI, MCP, OpenAPI), see this Task's Actor page: https://apify.com/autofacts/universal-web-printer.md

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`).
