Convert to PDF
Generic string-to-PDF converter.
Renders plain text, Markdown or HTML into a PDF with PDFKit and returns it base64-encoded, with an optional title, data blocks, page header, footer, watermark and page numbers.
Supported input types
text— rendered as-is, plain wrap.markdown— parsed withmarked; renders headings, paragraphs, bold/italic/code, ordered/unordered lists, blockquotes, links, horizontal rules.html— parsed withhtmlparser2; rendersh1..h6,p,strong/b,em/i,code/pre,ul/ol/li,blockquote,a,hr,br. Non-supported tags render as text. Images (<img>) are dropped — carry them as separate attachments if needed.
Page decoration (all optional)
metadata— object rendered as a key/value block above the body (e.g. From/To/Subject/Date for an email; Contract/Client/Date for a document).document_header— text painted at the top of every page (e.g. institutional header).document_footer— text painted at the bottom of every page (e.g. legal footer).watermark— rotated background text with configurable opacity.page_numbers— appends "Página N de M" to the bottom-right of every page.
Design constraints
- Pure input → output. No blob download, no external I/O, no Cosmos/Mongo touch. Fully testable in isolation.
- Reusable for any
string → PDFscenario (email body, contracts, manuals, logs). Not coupled to any specific domain. - Uses pdfkit (JS pure, no chromium). Fast and lightweight; suitable for envelopes.
How it works
- Resolves the config.
contentcomes from the config, or fromcontentin the incoming payload; an empty value fails the node. - Reads the layout:
input_type(defaulttext, case-insensitive),filename(defaultdocument.pdf),page_size(defaultA4) andpage_margin(default 50 points). A header adds 30 points to the top margin; a footer or page numbers add 30 points to the bottom margin. - Draws the optional blocks before the body, in this order:
title(withsubtitle),traceabilityandmetadata. When any of them is present, a fixed bold label precedes the body. - Draws the body:
textas is;markdownthrough the marked lexer (headings, paragraphs, bold, italic, inline code, links, lists, code blocks, blockquotes, rules);htmlthrough htmlparser2 (h1–h6,p,pre,blockquote,li,hr,br,b/strong,i/em,code,a). - Paints on every page the watermark,
document_header,document_footerand, withpage_numbers, a bottom-right page counter. - Returns
{ pdf_base64, filename, size_bytes, input_type, format: "pdf" }throughout.
In a workflow
The node as it appears in a workflow file (draft_nodes[]), and the envelope of a successful run.
{
"node_id": "node-render-summary",
"label": "Render summary PDF",
"operator_slug": "data.convert.to.pdf",
"operator_version": "1.0.0",
"config": {
"content": "{{ $json.summary_markdown }}",
"input_type": "markdown",
"filename": "case-summary.pdf",
"page_size": "A4",
"page_numbers": true,
"document_footer": {
"text": "Confidential. Generated by an automated workflow."
}
}
}{
"ok": true,
"data": {
"pdf_base64": "JVBERi0xLjMKJf////8KNyAwIG9iago8PAovVHlwZSAvUGFnZQo...",
"filename": "case-summary.pdf",
"size_bytes": 18432,
"input_type": "markdown",
"format": "pdf"
},
"port": "out"
}Configuration
-
contentstring Required -
The source content (plain text, Markdown, or HTML) to convert into a PDF.
-
input_typestring Optional -
How to interpret the content string.
-
filenamestring Optional -
Logical filename for the produced PDF (used in metadata and echoed in output).
-
page_sizestring Optional -
page_marginnumber Optional -
Uniform margin in points (72pt = 1in).
-
metadataobject Optional -
Key/value pairs rendered as a small table above the body.
-
document_headerobject Optional -
Text painted at the top of every page.
-
textstring Optional -
styleobject Optional -
-
font_sizenumber Optional -
Font size in points.
-
boldboolean Optional -
Whether the text is bold.
-
colorstring Optional -
Text color as hex (e.g. "#666666").
-
alignstring Optional -
Horizontal alignment.
-
-
-
watermarkobject Optional -
Rotated background text painted on every page.
-
textstring Optional -
opacitynumber Optional -
Opacity 0..1 (default 0.06).
-
rotationnumber Optional -
Rotation in degrees (default 45).
-
colorstring Optional -
Hex color (default "#000000").
-
font_sizenumber Optional -
Watermark font size (default 60pt).
-
-
page_numbersboolean Optional -
If true, prints "Página N de M" on the bottom-right of every page.
Its configuration shows the shared execution settings, but this node does not apply retries (retryOnFail, maxTries) yet. continueOnFail is not applied by any node.
Behaviour in the code
What the implementation does with these keys beyond what the schema says.
-
page_margin - The code default is 50 points, not the 40 shown in the schema. Non-numeric values fall back to 50.
-
titleRead by the code, not declared - Not declared. Centered bold title (14 pt) with an optional
subtitle(also undeclared) and a rule below. -
traceabilityRead by the code, not declared - Not declared. Object of key/value pairs drawn as a small monospaced block; null or empty values are skipped.
metadataworks the same way with a regular font. -
watermark - Code defaults:
opacity0.06,rotation-30 degrees,font_size40,color#000000(the schema text says 45 degrees and 60 pt). -
document_header textplusstyle(align,color,font_sizedefault 8,bold). Long text is cut with an ellipsis: one line in the header, two lines indocument_footer.
Output ports
out default The PDF was generated. size_bytes is the raw PDF size before base64.
{
"pdf_base64": "JVBERi0xLjMKJf////8KNyAwIG9iago8PAovVHlwZSAvUGFnZQo...",
"filename": "case-summary.pdf",
"size_bytes": 18432,
"input_type": "markdown",
"format": "pdf"
}error content is empty or PDFKit failed.
{
"error": "content is required"
}In expressions
What a later node can read from this node's output with $("Convert to PDF").item.json.<path> (write your node's label instead of Convert to PDF). Editor marks the paths the workflow editor suggests under Previous Nodes (the output contract); Worker marks the paths the worker really returns through out, from the output shown in Ports.
| Expression | Editor | Worker |
|---|---|---|
$("Convert to PDF").item.json.pdf_base64PDF binary base64-encoded (fits Link Loom envelope constraints). | ||
$("Convert to PDF").item.json.filename | ||
$("Convert to PDF").item.json.size_bytesRaw PDF size in bytes (pre-base64). | ||
$("Convert to PDF").item.json.input_typeEcho of the input_type used. | ||
$("Convert to PDF").item.json.formatAlways 'pdf'. |
Errors
| Message | Port | Cause and fix |
|---|---|---|
content is required | error | No content in the config or in the payload. Map it, for example {{ $json.summary_markdown }}. |
Cannot read properties of undefined (reading '0') | error | page_size is not a size PDFKit knows. Use A4 or Letter. |
Input contract
-
contentstring Required -
input_typestring Optional
Output contract
-
pdf_base64string Optional -
PDF binary base64-encoded (fits Link Loom envelope constraints).
-
filenamestring Optional -
size_bytesnumber Optional -
Raw PDF size in bytes (pre-base64).
-
input_typestring Optional -
Echo of the input_type used.
-
formatstring Optional -
Always 'pdf'.
Contracts (JSON Schema)
The definition exactly as the orchestrator declares it. All is the whole *.definition.js; compare it with the sections above to spot differences between the documentation and the schema. Use it to validate a node before you publish.
{
"slug": "data.convert.to.pdf",
"name": "Convert to PDF",
"category": "data",
"version": "1.0.0",
"description": "Generic string-to-PDF converter. Accepts plain text, Markdown, or HTML and produces a PDF binary encoded as base64 in the envelope (Link Loom envelopes do not transport raw Buffers between nodes).\n\n**Supported input types**\n- `text` — rendered as-is, plain wrap.\n- `markdown` — parsed with `marked`; renders headings, paragraphs, bold/italic/code, ordered/unordered lists, blockquotes, links, horizontal rules.\n- `html` — parsed with `htmlparser2`; renders `h1..h6`, `p`, `strong/b`, `em/i`, `code/pre`, `ul/ol/li`, `blockquote`, `a`, `hr`, `br`. Non-supported tags render as text. Images (`<img>`) are dropped — carry them as separate attachments if needed.\n\n**Page decoration (all optional)**\n- `metadata` — object rendered as a key/value block above the body (e.g. From/To/Subject/Date for an email; Contract/Client/Date for a document).\n- `document_header` — text painted at the top of every page (e.g. institutional header).\n- `document_footer` — text painted at the bottom of every page (e.g. legal footer).\n- `watermark` — rotated background text with configurable opacity.\n- `page_numbers` — appends \"Página N de M\" to the bottom-right of every page.\n\n**Design constraints**\n- Pure input → output. No blob download, no external I/O, no Cosmos/Mongo touch. Fully testable in isolation.\n- Reusable for any `string → PDF` scenario (email body, contracts, manuals, logs). Not coupled to any specific domain.\n- Uses pdfkit (JS pure, no chromium). Fast and lightweight; suitable for envelopes.",
"capabilities": [
"pdf",
"convert",
"html-to-pdf",
"markdown-to-pdf",
"text-to-pdf"
],
"config_schema": {
"type": "object",
"required": [
"content"
],
"properties": {
"content": {
"type": "string",
"title": "Content",
"format": "textarea",
"description": "The source content (plain text, Markdown, or HTML) to convert into a PDF."
},
"input_type": {
"type": "string",
"enum": [
"text",
"markdown",
"html"
],
"default": "text",
"title": "Input Type",
"description": "How to interpret the content string."
},
"filename": {
"type": "string",
"default": "document.pdf",
"title": "Filename",
"description": "Logical filename for the produced PDF (used in metadata and echoed in output)."
},
"page_size": {
"type": "string",
"enum": [
"A4",
"Letter"
],
"default": "A4",
"title": "Page Size"
},
"page_margin": {
"type": "number",
"default": 40,
"title": "Page Margin (points)",
"description": "Uniform margin in points (72pt = 1in)."
},
"metadata": {
"type": "object",
"title": "Metadata Block",
"description": "Key/value pairs rendered as a small table above the body.",
"additionalProperties": {
"type": "string"
}
},
"document_header": {
"type": "object",
"title": "Page Header",
"description": "Text painted at the top of every page.",
"properties": {
"text": {
"type": "string"
},
"style": {
"type": "object",
"properties": {
"font_size": {
"type": "number",
"description": "Font size in points."
},
"bold": {
"type": "boolean",
"description": "Whether the text is bold."
},
"color": {
"type": "string",
"description": "Text color as hex (e.g. \"#666666\")."
},
"align": {
"type": "string",
"enum": [
"left",
"center",
"right"
],
"description": "Horizontal alignment."
}
}
}
}
},
"document_footer": {
"type": "object",
"title": "Page Footer",
"description": "Text painted at the bottom of every page (e.g. legal disclaimer).",
"properties": {
"text": {
"type": "string"
},
"style": {
"type": "object",
"properties": {
"font_size": {
"type": "number",
"description": "Font size in points."
},
"bold": {
"type": "boolean",
"description": "Whether the text is bold."
},
"color": {
"type": "string",
"description": "Text color as hex (e.g. \"#666666\")."
},
"align": {
"type": "string",
"enum": [
"left",
"center",
"right"
],
"description": "Horizontal alignment."
}
}
}
}
},
"watermark": {
"type": "object",
"title": "Watermark",
"description": "Rotated background text painted on every page.",
"properties": {
"text": {
"type": "string"
},
"opacity": {
"type": "number",
"description": "Opacity 0..1 (default 0.06)."
},
"rotation": {
"type": "number",
"description": "Rotation in degrees (default 45)."
},
"color": {
"type": "string",
"description": "Hex color (default \"#000000\")."
},
"font_size": {
"type": "number",
"description": "Watermark font size (default 60pt)."
}
}
},
"page_numbers": {
"type": "boolean",
"default": false,
"title": "Show Page Numbers",
"description": "If true, prints \"Página N de M\" on the bottom-right of every page."
},
"execution": {
"type": "object",
"title": "Execution Settings",
"properties": {
"alwaysOutputData": {
"type": "boolean",
"title": "Always Output Data",
"description": "Always output data, even on error (if configured).",
"default": false
},
"retryOnFail": {
"type": "boolean",
"title": "Retry On Fail",
"description": "Retry the execution if it fails.",
"default": false
},
"maxTries": {
"type": "integer",
"title": "Max Retries",
"description": "Number of retries.",
"default": 3,
"displayOptions": {
"show": {
"retryOnFail": [
true
]
}
}
},
"waitBetweenTries": {
"type": "integer",
"title": "Wait Between Retries (ms)",
"default": 1000,
"displayOptions": {
"show": {
"retryOnFail": [
true
]
}
}
},
"continueOnFail": {
"type": "boolean",
"title": "Continue On Fail",
"description": "Do not crash workflow on error.",
"default": false
},
"timeout_ms": {
"type": "integer",
"title": "Timeout (ms)",
"description": "Max execution time for this node before it is killed, in milliseconds. Honored by long-running operators (e.g. OCR/extraction, inline code). Default 300000 (5 min).",
"default": 300000
}
}
}
}
},
"input_contract_schema": {
"type": "object",
"required": [
"content"
],
"properties": {
"content": {
"type": "string"
},
"input_type": {
"type": "string"
}
}
},
"output_contract_schema": {
"type": "object",
"properties": {
"pdf_base64": {
"type": "string",
"description": "PDF binary base64-encoded (fits Link Loom envelope constraints)."
},
"filename": {
"type": "string"
},
"size_bytes": {
"type": "number",
"description": "Raw PDF size in bytes (pre-base64)."
},
"input_type": {
"type": "string",
"description": "Echo of the input_type used."
},
"format": {
"type": "string",
"description": "Always 'pdf'."
}
}
},
"ports": [
{
"port_id": "out",
"label": "PDF",
"description": "PDF generated successfully.",
"is_default": true,
"supports_condition": true
},
{
"port_id": "error",
"label": "Error",
"description": "Conversion failed.",
"is_default": false,
"supports_condition": false
}
],
"execution_mode": "sync",
"required_resources": [],
"tags": [
"pdf",
"convert",
"html",
"markdown",
"text",
"render"
],
"is_stateful": false,
"publisher": {
"identity": "org_link_loom",
"profile": {
"name": "Link Loom",
"verified": true,
"url": "https://me.veripass.com/link-loom",
"logo_url": null
}
}
}{
"type": "object",
"required": [
"content"
],
"properties": {
"content": {
"type": "string",
"title": "Content",
"format": "textarea",
"description": "The source content (plain text, Markdown, or HTML) to convert into a PDF."
},
"input_type": {
"type": "string",
"enum": [
"text",
"markdown",
"html"
],
"default": "text",
"title": "Input Type",
"description": "How to interpret the content string."
},
"filename": {
"type": "string",
"default": "document.pdf",
"title": "Filename",
"description": "Logical filename for the produced PDF (used in metadata and echoed in output)."
},
"page_size": {
"type": "string",
"enum": [
"A4",
"Letter"
],
"default": "A4",
"title": "Page Size"
},
"page_margin": {
"type": "number",
"default": 40,
"title": "Page Margin (points)",
"description": "Uniform margin in points (72pt = 1in)."
},
"metadata": {
"type": "object",
"title": "Metadata Block",
"description": "Key/value pairs rendered as a small table above the body.",
"additionalProperties": {
"type": "string"
}
},
"document_header": {
"type": "object",
"title": "Page Header",
"description": "Text painted at the top of every page.",
"properties": {
"text": {
"type": "string"
},
"style": {
"type": "object",
"properties": {
"font_size": {
"type": "number",
"description": "Font size in points."
},
"bold": {
"type": "boolean",
"description": "Whether the text is bold."
},
"color": {
"type": "string",
"description": "Text color as hex (e.g. \"#666666\")."
},
"align": {
"type": "string",
"enum": [
"left",
"center",
"right"
],
"description": "Horizontal alignment."
}
}
}
}
},
"document_footer": {
"type": "object",
"title": "Page Footer",
"description": "Text painted at the bottom of every page (e.g. legal disclaimer).",
"properties": {
"text": {
"type": "string"
},
"style": {
"type": "object",
"properties": {
"font_size": {
"type": "number",
"description": "Font size in points."
},
"bold": {
"type": "boolean",
"description": "Whether the text is bold."
},
"color": {
"type": "string",
"description": "Text color as hex (e.g. \"#666666\")."
},
"align": {
"type": "string",
"enum": [
"left",
"center",
"right"
],
"description": "Horizontal alignment."
}
}
}
}
},
"watermark": {
"type": "object",
"title": "Watermark",
"description": "Rotated background text painted on every page.",
"properties": {
"text": {
"type": "string"
},
"opacity": {
"type": "number",
"description": "Opacity 0..1 (default 0.06)."
},
"rotation": {
"type": "number",
"description": "Rotation in degrees (default 45)."
},
"color": {
"type": "string",
"description": "Hex color (default \"#000000\")."
},
"font_size": {
"type": "number",
"description": "Watermark font size (default 60pt)."
}
}
},
"page_numbers": {
"type": "boolean",
"default": false,
"title": "Show Page Numbers",
"description": "If true, prints \"Página N de M\" on the bottom-right of every page."
},
"execution": {
"type": "object",
"title": "Execution Settings",
"properties": {
"alwaysOutputData": {
"type": "boolean",
"title": "Always Output Data",
"description": "Always output data, even on error (if configured).",
"default": false
},
"retryOnFail": {
"type": "boolean",
"title": "Retry On Fail",
"description": "Retry the execution if it fails.",
"default": false
},
"maxTries": {
"type": "integer",
"title": "Max Retries",
"description": "Number of retries.",
"default": 3,
"displayOptions": {
"show": {
"retryOnFail": [
true
]
}
}
},
"waitBetweenTries": {
"type": "integer",
"title": "Wait Between Retries (ms)",
"default": 1000,
"displayOptions": {
"show": {
"retryOnFail": [
true
]
}
}
},
"continueOnFail": {
"type": "boolean",
"title": "Continue On Fail",
"description": "Do not crash workflow on error.",
"default": false
},
"timeout_ms": {
"type": "integer",
"title": "Timeout (ms)",
"description": "Max execution time for this node before it is killed, in milliseconds. Honored by long-running operators (e.g. OCR/extraction, inline code). Default 300000 (5 min).",
"default": 300000
}
}
}
}
}{
"type": "object",
"required": [
"content"
],
"properties": {
"content": {
"type": "string"
},
"input_type": {
"type": "string"
}
}
}{
"type": "object",
"properties": {
"pdf_base64": {
"type": "string",
"description": "PDF binary base64-encoded (fits Link Loom envelope constraints)."
},
"filename": {
"type": "string"
},
"size_bytes": {
"type": "number",
"description": "Raw PDF size in bytes (pre-base64)."
},
"input_type": {
"type": "string",
"description": "Echo of the input_type used."
},
"format": {
"type": "string",
"description": "Always 'pdf'."
}
}
}[
{
"port_id": "out",
"label": "PDF",
"description": "PDF generated successfully.",
"is_default": true,
"supports_condition": true
},
{
"port_id": "error",
"label": "Error",
"description": "Conversion failed.",
"is_default": false,
"supports_condition": false
}
]Execution
- Execution
sync- Stateful
- No
- Retries (
retryOnFail) - No
- Capabilities
pdfconverthtml-to-pdfmarkdown-to-pdftext-to-pdf- Tags
pdfconverthtmlmarkdowntextrender
Notes and limits
- Uses the PDF standard fonts Helvetica and Courier: characters outside their Latin set (for example Chinese, Japanese or emoji) are not rendered correctly.
- Fixed labels are in Spanish: "Trazabilidad", "Encabezados del correo", "Contenido del correo" and "Página N de M".
- Images are ignored, Markdown tables are not drawn and HTML tables are flattened into plain paragraphs.
- The whole PDF is held in memory and travels base64-encoded in the payload (about 4/3 of its size). The incoming payload is replaced by the result.
- The worker does not set
ok(the example showstrue); the engine routes only byport.
Reviewed against the orchestrator code · 31e874b · 2026-11-26