---
name: mergecanvas
description: Use when you need one filled PDF per spreadsheet row (mail merge into PDF forms or flat PDFs) from a CSV and a template, or need to write a MergeCanvas recipe.
---

# Mail merge a PDF template with a spreadsheet

A recipe is a small JSON file: which template, where each column goes, how to name the files.

## Write a recipe from the headers

1. Get the column names (row 1 of the CSV or sheet). Each `fields[].column` must match one exactly.
2. For a PDF with form fields, list the fields (tool `inspect_pdf_template`, or pdf-lib `getForm().getFields()`) and map each column to a field name: `{"type":"form","name":"<field name>"}`.
3. For a flat PDF, place text: `{"type":"text","page":1,"x":72,"y":700,"size":12,"color":"#000000","align":"left"}`.
4. Set `output.fileName` from columns, for example `"{{Last name}} certificate"`, and `output.mode` to `zip` (one file per row) or `combined` (one PDF).

Schema: https://mergecanvas.duewright.com/schema/recipe.json

Rules:

- PDF text targets: x and y are in PDF points (1/72 inch); the origin is the bottom-left corner of the page; page is 1-based.
- Image text targets: x and y are in image pixels; the origin is the top-left corner of the image.
- x is the anchor for align: the left edge (left), the centre (center) or the right edge (right) of the text.
- y is the text baseline.
- maxWidth shrinks the font size until the text fits that width; the size never goes below 4. Text is never wrapped.
- Newlines in a cell become spaces.
- PDF text is drawn in Helvetica (WinAnsi only). Curly quotes and dashes become ASCII; other characters outside WinAnsi print as "?".
- Form targets fill a PDF form field by its exact name; the form is flattened in the output.
- A checkbox is checked when the cell is x, yes, y, true, 1, on, checked or ja (any case).
- A dropdown, list or radio value must equal one of the field options exactly, or the field is left as it is.
- Placeholder targets replace {{name}} in a Word .docx template.
- output.fileName is a pattern with {{Column}} tokens, without extension. mode zip gives one file per row; combined gives one PDF (PDF templates only).

## Run the merge with a shell (PDF templates only)

Needs Node 20 or later. Put the script in an empty folder and install its two libraries next to it:

```sh
curl -sO https://mergecanvas.duewright.com/skill/merge.mjs
npm i pdf-lib@1.17.1 papaparse@5.7.1
node merge.mjs --recipe recipe.json --data rows.csv --template template.pdf --out out/ [--combined]
```

It writes one PDF per row (names from `output.fileName`), or one combined PDF with `--combined` or `"mode":"combined"`, and prints each path. Each page gets a small "Made with MergeCanvas · mergecanvas.duewright.com" line at the bottom, as in the free editor. Files stay on your machine.

## The MCP endpoint

Endpoint: https://mergecanvas.duewright.com/mcp (Streamable HTTP, stateless, no login). Tools, all read-only:

- `get_recipe_format`: the schema, the rules above and two example recipes.
- `inspect_pdf_template`: `url` of a public https PDF (at most 3 MB); returns pages and form fields.
- `check_recipe`: `recipe` and optional `columns`; returns errors, unknown columns and an editor link.

```sh
curl -s -X POST https://mergecanvas.duewright.com/mcp -H 'content-type: application/json' \
  -H 'accept: application/json, text/event-stream' \
  -d '{"jsonrpc":"2.0","id":1,"method":"tools/list"}'
```

Free: 50 tool calls per IP per UTC day, 2000 per day for all callers.

## The editor

Open https://mergecanvas.duewright.com/app#recipe=<base64url of the recipe JSON> (`check_recipe` returns this link). The link carries only the recipe; the person adds the template and the spreadsheet in the browser, where the merge runs. Word (.docx) and image (PNG, JPG) templates go to the editor.

## More

Agents page: https://mergecanvas.duewright.com/agents. Pricing: https://mergecanvas.duewright.com/pricing?ref=agent
