# Convert Markdown to PDF — FileToPDF.dev

> Render Markdown (with optional CSS) into a clean PDF. See the documentation.

- Key: `filetopdf_dev-convert-markdown`
- Type: Action (Write)
- Version: 0.0.1
- App: FileToPDF.dev (`filetopdf_dev`) — https://pipedream.com/apps/filetopdf-dev.md
- This page (HTML): https://pipedream.com/apps/filetopdf-dev/actions/convert-markdown
- Hints: open-world
- Source: https://github.com/PipedreamHQ/pipedream/blob/master/components/filetopdf_dev/actions/convert-markdown/convert-markdown.mjs

## Description

Render Markdown (with optional CSS) into a clean PDF. [See the documentation](https://filetopdf.dev/markdown).

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `markdown` | `string` | Yes | The Markdown content to render. A sensible default stylesheet is applied when no CSS is provided. |
| `css` | `string` | No | Optional CSS to style the rendered Markdown. Overrides the default stylesheet. Use @page rules for page size/margins, or set them in the options below. |
| `landscape` | `boolean` | No | Render the page in landscape orientation. |
| `paperWidth` | `string` | No | Default 8.5 (Letter). A4 is 8.27. |
| `paperHeight` | `string` | No | Default 11 (Letter). A4 is 11.7. |
| `marginTop` | `string` | No | Top page margin in inches. |
| `marginBottom` | `string` | No | Bottom page margin in inches. |
| `marginLeft` | `string` | No | Left page margin in inches. |
| `marginRight` | `string` | No | Right page margin in inches. |
| `scale` | `string` | No | Render scale, e.g. 0.8 to shrink content. Default 1. |
| `printBackground` | `boolean` | No | Include background colors and images in the PDF. |
| `preferCssPageSize` | `boolean` | No | Use the page size declared in the document's CSS @page rules. |
| `nativePageRanges` | `string` | No | Limit output to specific pages, e.g. 1-3 or 2,5-7. |
| `pdfa` | `string` | No | Produce an ISO-standardised archival PDF. |
| `pdfua` | `boolean` | No | Produce an accessible, tagged PDF/UA document. |
| `userPassword` | `string` | No | Encrypt the resulting PDF; this password is required to open it. |
| `ownerPassword` | `string` | No | Restrict editing/printing of the resulting PDF. |
| `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": "filetopdf_dev",
      },
    },
  },
)

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: "filetopdf_dev-convert-markdown",
  arguments: {
    markdown: "Markdown",
    css: "CSS",
  },
})
```

**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: "filetopdf_dev-convert-markdown",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    filetopdf_dev: { authProvisionId: "apn_xxxxxxx" },
    markdown: "Markdown",
    css: "CSS",
  },
})

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": "filetopdf_dev-convert-markdown",
    "configured_props": {
      "filetopdf_dev": { "authProvisionId": "apn_xxxxxxx" },
      "markdown": "Markdown",
      "css": "CSS"
    }
  }'
```

---

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