# Get PDF — Puppeteer

> Generate a PDF of a page using Puppeteer. See the documentation

- Key: `puppeteer-get-pdf`
- Type: Action (Read-only)
- Version: 1.0.5
- App: Puppeteer (`puppeteer`) — https://pipedream.com/apps/puppeteer.md
- This page (HTML): https://pipedream.com/apps/puppeteer/actions/get-pdf
- Hints: read-only · open-world
- Source: https://github.com/PipedreamHQ/pipedream/blob/master/components/puppeteer/actions/get-pdf/get-pdf.mjs

## Description

Generate a PDF of a page using Puppeteer. [See the documentation](https://pptr.dev/api/puppeteer.page.pdf)

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `url` | `string` | Yes | The URL of the page to scrape. For example, https://example.com. |
| `downloadPath` | `string` | No | Download the PDF to the /tmp directory with the specified filename |
| `displayHeaderFooter` | `boolean` | No | Whether to show the header and footer. |
| `footerTemplate` | `string` | No | HTML template for the print footer. |
| `format` | `string` | No | The paper format of the PDF |
| `headerTemplate` | `string` | No | HTML template for the print header. Should be valid HTML with the following classes used to inject values into them: date - formatted print date, title - document title, url - document location, pageNumber - current page number, totalPages - total pages in the document. |
| `height` | `string` | No | Sets the height of paper. You can pass in a number or a string with a unit. |
| `landscape` | `boolean` | No | Whether to print in landscape orientation. |
| `marginBottom` | `string` | No | Margin for the bottom of the page |
| `marginLeft` | `string` | No | Margin for the left side of the page |
| `marginRight` | `string` | No | Margin for the right side of the page |
| `marginTop` | `string` | No | Margin for the top of the page |
| `omitBackground` | `boolean` | No | Hides default white background and allows generating pdfs with transparency. |
| `pageRanges` | `string` | No | Paper ranges to print, e.g. 1-5, 8, 11-13. |
| `preferCSSPageSize` | `boolean` | No | Give any CSS @page size declared in the page priority over what is declared in the width or height or format option. |
| `printBackground` | `boolean` | No | Set to true to print background graphics. |
| `scale` | `string` | No | Scales the rendering of the web page. Amount must be between 0.1 and 2. |
| `timeout` | `integer` | No | Timeout in milliseconds. Pass 0 to disable timeout. |
| `width` | `string` | No | Sets the width of paper. You can pass in a number or a string with a unit. |
| `syncDir` | `dir` | Yes | SyncDir |

## Run it

**MCP**

```ts
import { Client } from "@modelcontextprotocol/sdk/client/index.js"
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js"
import { PipedreamClient } from "@pipedream/sdk"

const pd = new PipedreamClient({
  projectId: process.env.PIPEDREAM_PROJECT_ID!,
  clientId: process.env.PIPEDREAM_CLIENT_ID!,
  clientSecret: process.env.PIPEDREAM_CLIENT_SECRET!,
  projectEnvironment: "production",
})

const accessToken = await pd.rawAccessToken

const transport = new StreamableHTTPClientTransport(
  new URL("https://remote.mcp.pipedream.net/v3"),
  {
    requestInit: {
      headers: {
        Authorization: `Bearer ${accessToken}`,
        "x-pd-project-id": process.env.PIPEDREAM_PROJECT_ID!,
        "x-pd-environment": "production",
        "x-pd-external-user-id": "{external_user_id}", // any stable ID for this user in your system
        "x-pd-app-slug": "puppeteer",
      },
    },
  },
)

const mcp = new Client({ name: "my-agent", version: "1.0.0" })
await mcp.connect(transport)

const { tools } = await mcp.listTools()

// listTools() hands your model this tool's input schema, so it can
// fill the arguments itself:
const result = await mcp.callTool({
  name: "puppeteer-get-pdf",
  arguments: {
    url: "URL",
    downloadPath: "Download Path",
  },
})
```

**TypeScript**

```ts
import { PipedreamClient } from "@pipedream/sdk"

const pd = new PipedreamClient({
  projectId: process.env.PIPEDREAM_PROJECT_ID!,
  clientId: process.env.PIPEDREAM_CLIENT_ID!,
  clientSecret: process.env.PIPEDREAM_CLIENT_SECRET!,
  projectEnvironment: "production",
})

const result = await pd.actions.run({
  id: "puppeteer-get-pdf",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    puppeteer: { authProvisionId: "apn_xxxxxxx" },
    url: "URL",
    downloadPath: "Download Path",
  },
})

console.log(result)
```

**cURL**

```bash
curl -X POST https://api.pipedream.com/v1/connect/{project_id}/actions/run \
  -H "Content-Type: application/json" \
  -H "X-PD-Environment: production" \
  -H "Authorization: Bearer {access_token}" \
  -d '{
    "external_user_id": "{external_user_id}",
    "id": "puppeteer-get-pdf",
    "configured_props": {
      "puppeteer": { "authProvisionId": "apn_xxxxxxx" },
      "url": "URL",
      "downloadPath": "Download Path"
    }
  }'
```

---

- App: https://pipedream.com/apps/puppeteer.md · All apps: https://pipedream.com/apps
