# Convert Web URL to Specified Format — ConvertAPI

> Converts a website page to a specified format. See the documentation

- Key: `convertapi-convert-web-url`
- Type: Action (Read-only)
- Version: 0.0.3
- App: ConvertAPI (`convertapi`) — https://pipedream.com/apps/convertapi.md
- This page (HTML): https://pipedream.com/apps/convertapi/actions/convert-web-url
- Hints: read-only · open-world
- Source: https://github.com/PipedreamHQ/pipedream/blob/master/components/convertapi/actions/convert-web-url/convert-web-url.mjs

## Description

Converts a website page to a specified format. [See the documentation](https://v2.convertapi.com/info/openapi)

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `url` | `string` | Yes | The website URL to be converted to a specified format. |
| `formatTo` | `string` | Yes | The format you want to convert the URL to. |
| `fileName` | `string` | No | Converted output file name without extension. The extension will be added automatically. |
| `timeout` | `string` | No | Conversion timeout in seconds. |
| `conversionDelay` | `integer` | No | Delay in seconds before page load and file creation. Sometimes useful to let web page fully load. |
| `authUsername` | `string` | No | HTTP authentication username. Could be used if conversion web page is protected with HTTP authentication. |
| `authPassword` | `string` | No | HTTP authentication password. Could be used if conversion web page is protected with HTTP authentication. |
| `adBlock` | `boolean` | No | Block ads in converting page. |
| `cookieConsentBlock` | `boolean` | No | Tries to remove EU regulation required cookie warnings from web pages. |
| `cookies` | `string` | No | Set additional cookies for the page request. Exaple: cookiename1=cookievalue1; cookiename2=cookievalue2; cookiename3=cookievalue3 |
| `javaScript` | `boolean` | No | Allow web pages to run JavaScript. |
| `waitElement` | `string` | No | Element selector string of the DOM element. Converter will wait for this element to appear in DOM before conversion begins. |
| `userJs` | `string` | No | Execute provided JavaScript before conversion begins. |
| `userCss` | `string` | No | Apply additional CSS before conversion begins. |
| `hideElements` | `string` | No | Element selector string of the DOM elements that need to be hidden during conversion. |
| `cssMediaType` | `string` | No | Use CSS media type in conversion process. |
| `imageWidth` | `integer` | No | Image width in pixels. |
| `imageHeight` | `integer` | No | Image height in pixels. |
| `imageQuality` | `integer` | No | Set output image quality. |
| `cropElement` | `string` | No | Element selector string of the DOM element that should be converted. Element will be cropped from the document. |
| `cropX` | `integer` | No | Screenshot crop X offset. |
| `cropY` | `integer` | No | Screenshot crop Y offset. |
| `cropWidth` | `integer` | No | Screenshot crop width. |
| `cropHeight` | `integer` | No | Screenshot crop height. |
| `zoom` | `integer` | No | Set the default zoom level of webpages. |
| `loadLazyContent` | `boolean` | No | Load page images that loads only when they are visible. |
| `viewportWidth` | `integer` | No | Sets browser viewport width. |
| `viewportHeight` | `integer` | No | Sets browser viewport height. |
| `respectViewport` | `boolean` | No | If true, the converter will generate PDF as the content looks like in the browser. If is set to false, the converter acts like Chrome print to PDF function. |
| `scale` | `integer` | No | Set web page scale value in percentage. |
| `pageOrientation` | `string` | No | PDF page orientation |
| `pageSize` | `string` | No | PDF Page Size |
| `pageWidth` | `integer` | No | Custom page width in millimeters (mm). This option override PageSize option. |
| `pageHeight` | `integer` | No | Custom page height in millimeters (mm). This option override PageSize option. |
| `marginTop` | `integer` | No | Set the page top margin in millimeters (mm). |
| `marginRight` | `integer` | No | Set the page right margin in millimeters (mm). |
| `marginBottom` | `integer` | No | Set the page bottom margin in millimeters (mm). |
| `marginLeft` | `integer` | No | Set the page left margin in millimeters (mm). |
| `pageRange` | `string` | No | Set page range. Example 1-10 or 1,2,5. |
| `background` | `boolean` | No | Convert web page background. |
| `fixedElements` | `string` | No | Change fixed elements CSS 'position' property to adapt page for conversion |
| `showElements` | `string` | No | Element selector string of the DOM elements that should be visible during conversion. Other elements will be hidden. |
| `avoidBreakElements` | `string` | No | CSS selector for the elements that pages should not break. |
| `breakBeforeElements` | `string` | No | CSS selector for the elements that should apply page break before it. |
| `breakAfterElements` | `string` | No | CSS selector for the elements that should apply page break after it. |
| `compressPDF` | `boolean` | No | It tries to produce smaller output files but requires Adobe Reader 6, released in 2003 or newer, to view created PDF files. |
| `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": "convertapi",
      },
    },
  },
)

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: "convertapi-convert-web-url",
  arguments: {
    url: "URL",
    formatTo: "Format To",
  },
})
```

**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: "convertapi-convert-web-url",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    convertapi: { authProvisionId: "apn_xxxxxxx" },
    url: "URL",
    formatTo: "Format To",
  },
})

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": "convertapi-convert-web-url",
    "configured_props": {
      "convertapi": { "authProvisionId": "apn_xxxxxxx" },
      "url": "URL",
      "formatTo": "Format To"
    }
  }'
```

---

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