# Create PDF — CraftMyPDF

> Create a new pdf. See the documentation

- Key: `craftmypdf-create-pdf`
- Type: Action (Write)
- Version: 0.0.2
- App: CraftMyPDF (`craftmypdf`) — https://pipedream.com/apps/craftmypdf.md
- This page (HTML): https://pipedream.com/apps/craftmypdf/actions/create-pdf
- Hints: open-world
- Source: https://github.com/PipedreamHQ/pipedream/blob/master/components/craftmypdf/actions/create-pdf/create-pdf.mjs

## Description

Create a new pdf. [See the documentation](https://craftmypdf.com/docs/index.html#tag/PDF-Generation-API/operation/create)

## Props

| Prop | Type | Required | Description |
|---|---|---|---|
| `data` | `string` | Yes | JSON data based on the template structure. |
| `loadDataFrom` | `string` | No | Load data from an external URL. If this is specified, it will overwrite the `data`` property. |
| `templateId` | `string` | Yes | The Id of the template. Options are loaded from the connected account. |
| `version` | `string` | No | To generate a PDF using a specific version of the template. We use the latest template version unless you specify otherwise. Options are loaded from the connected account. |
| `expiration` | `integer` | No | Expiration of the generated PDF in minutes. Default to 5 minutes. Range between 1 minute and 24 hours. |
| `outputFile` | `string` | No | Default to 'output.pdf'. |
| `isCMYK` | `boolean` | No | Use CMYK color profile, default to 'false'. |
| `imageResampleRes` | `integer` | No | Optimize/downsample images of current PDF to a resolution(in DPI). This helps to reduce the PDF file size. Suggested values are 1200, 600, 300, 150 or 72. |
| `cloudStorage` | `integer` | No | Upload the generated PDFs/images to our storage CDN(Except export_type=file), default to 1. If you have configured Post Actions to upload the PDFs/Images to your own S3, please set it to 0. |
| `pdfStandard` | `string` | No | Default to PDF1.7. PDFA3 is an experimental feature. |
| `passwordProtected` | `boolean` | Yes | Enable password protection. |

## 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": "craftmypdf",
      },
    },
  },
)

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: "craftmypdf-create-pdf",
  arguments: {
    data: "Data",
    loadDataFrom: "Load Data From",
  },
})
```

**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: "craftmypdf-create-pdf",
  externalUserId: "{external_user_id}", // any stable ID for this user in your system
  configuredProps: {
    craftmypdf: { authProvisionId: "apn_xxxxxxx" },
    data: "Data",
    loadDataFrom: "Load Data From",
  },
})

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": "craftmypdf-create-pdf",
    "configured_props": {
      "craftmypdf": { "authProvisionId": "apn_xxxxxxx" },
      "data": "Data",
      "loadDataFrom": "Load Data From"
    }
  }'
```

---

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