Markdown To Pdf icon

Markdown To Pdf

Convert Markdown text into a PDF file

Markdown To Pdf

AI-generated

Summary

Converts Markdown text into a PDF file for each input item, using headless Chromium (Puppeteer), and returns it as binary data. Supports GitHub-flavored Markdown, syntax-highlighted code blocks, and KaTeX math.

Inputs

  • markdown — Markdown to convert. If the incoming item's JSON has a non-empty markdown field, that value takes precedence over this parameter. If neither yields non-blank text, the item errors with 'Markdown input is empty or invalid'.
  • fileName — Output file name template (default file-{{ $index }}). {{ $index }} is replaced by the 1-based item number and {{ $itemIndex }} by the 0-based index. .pdf is appended if missing; a blank result falls back to file-N.pdf.
  • pdfFormat — Page size: A4 (default), Letter, or Legal. Pages use fixed margins of 20mm top/bottom and 15mm left/right.

Output shape

One output item per input item, with JSON { fileName, size } (size is the PDF byte length) and the PDF in binary property data (application/pdf). Each output is paired to its input item.

Rendered HTML is sanitized (sanitize-html), so scripts and unlisted tags or attributes are stripped. Math is rendered with $...$ (inline) and $$...$$ (display) delimiters. With Continue On Fail enabled, failed items return { error: message } with no binary data. Otherwise the first error aborts the node. The node launches a headless Chromium with --no-sandbox, so the host must have Puppeteer/Chromium available. Images referenced by URL are allowed through the sanitizer.

Examples

Example 1: Turn an AI-generated report into a PDF and email it

Leave Markdown empty and pass the text in a markdown JSON field from the previous node. Set File Name to report-{{ $index }} and PDF Format to A4. Connect the output to an email node and attach binary property data.

Example 2: Generate a US-letter document from a fixed template

Enter Markdown directly in the Markdown field, including code fences and $E=mc^2$ math. Set PDF Format to Letter and File Name to notes.

Links

Discussion