Generate PDFs, screenshots, and EU e-invoices (Factur-X / ZUGFeRD) from your Airtable data with PolyDoc.
This repo holds two things:
recipes/- copy-paste scripts for the Airtable automation "Run a script" action. Available now. Three angles, mirroring the PolyDoc product:html-url-to-pdf.js- render a URL, inline HTML, or a saved template to PDFurl-to-screenshot.js- capture a screenshot of a URL or HTMLgenerate-einvoice.js- produce a hybrid EN 16931 e-invoice PDF
src/buildRequestBody.ts- the shared, unit-tested PolyDoc request builder. Used by the recipes' logic today and by the Blocks SDK Marketplace extension (planned, seeROADMAP.md).
Airtable has no third-party automation-node SDK, so PolyDoc plugs in two ways:
| "Run a script" recipe (this repo) | Marketplace extension (planned) | |
|---|---|---|
| What | Paste a script into an automation action | Installable UI panel in a base |
| Calls the API | Server-side, no CORS needed | Browser sandbox, needs gateway CORS |
| API key storage | Automation Secrets (secure) | globalConfig, visible to base collaborators |
| Plan | Paid only (Team ~$20/seat/mo; not on the Team trial) | Dev/build free; review needs a working base |
The "Run a script" action is not available on the free plan, so the recipes require a paid Airtable plan.
- Create a PolyDoc API key at dashboard.polydoc.tech.
- Create an Airtable personal access token with the
data.records:writescope (used to write the generated file into an attachment field). - In your base, add an automation with a trigger (e.g. "When record matches conditions") and a Run a script action.
- Paste the recipe for your angle. Add the input variables listed at the top of that recipe file, mapping record fields and storing the two keys as Secrets.
- Add an attachment field to hold the output and pass its name/id as
attachmentField. - Test the automation. The generated file lands in the attachment field.
The recipe asks PolyDoc for the file as binary, then uploads the bytes straight into the attachment cell via Airtable's upload-attachment endpoint (no external bucket needed). That endpoint caps at 5 MB per file. For larger output, switch the PolyDoc request to Cloud Storage delivery (a presigned URL to your own bucket) and write the resulting URL into the attachment field instead.
npm install
npm run typecheck # tsc --noEmit
npm test # unit tests (builder + recipe self-containment)
POLYDOC_API_KEY=<key> npm run test:integration # live sandbox smoke testsThe integration tests always send X-Sandbox: true, so they draw sandbox quota
(watermarked output) and never touch production. Space them out: the sandbox
rate limit is low (~5/sec). Set POLYDOC_TEMPLATE_ID to also exercise template
rendering.
The recipes/ files are self-contained for copy-paste (the Airtable script
editor has no module imports), so they inline the helpers from
recipes/_shared.js. test/recipes.test.ts enforces that
self-containment and verifies the base64 encoder.
See ROADMAP.md for the full plan, including the Marketplace
extension and the gateway CORS prerequisite.