Skip to main content

Generate Documents

The documents generate command generates a PDF document from an Eledo template.

eledoctl documents generate TEMPLATE_ID

Replace TEMPLATE_ID with the ID of the template you want to use. You can find available template IDs with:

eledoctl templates

Basic Usage

The most common use case is to generate a PDF and save it to a file:

eledoctl documents generate TEMPLATE_ID \
--add-field clientName="Acme Ltd" \
--add-field invoiceNumber="INV-2026-001" \
--output invoice.pdf

This command sends the provided fields to Eledo, generates the document, and writes the resulting PDF to invoice.pdf.


Input Modes

eledoctl documents generate supports two main ways to provide data:

  1. Simple fields with --add-field
  2. JSON payloads with --payload, --payload-file, or --payload-stdin

Use simple fields for quick commands and small documents.

Use JSON payloads when your data is structured, generated by another tool, or stored in a file.


Simple Fields

Use --add-field to provide individual values directly from the command line.

eledoctl documents generate TEMPLATE_ID \
--add-field firstName="John" \
--add-field lastName="Doe" \
--add-field email="john.doe@example.com" \
--output document.pdf

Each field is written as:

--add-field key=value

This mode is convenient for:

  • testing a template
  • generating a single document manually
  • simple shell scripts
  • templates with only a few fields

JSON Payload

For more complex documents, provide the input as JSON.

A JSON payload is useful when:

  • the document has many fields
  • the data comes from another command
  • the data is stored in a file
  • the template uses structured data
  • you want predictable input for scripts or automation

Inline JSON Payload

Use --payload to pass JSON directly on the command line:

eledoctl documents generate TEMPLATE_ID \
--payload '{"clientName":"Acme Ltd","invoiceNumber":"INV-2026-001"}' \
--output invoice.pdf

This is useful for small payloads, but longer JSON is usually easier to maintain in a file.


JSON Payload from a File

Use --payload-file to read the payload from a JSON file:

eledoctl documents generate TEMPLATE_ID \
--payload-file invoice-data.json \
--output invoice.pdf

Example invoice-data.json:

{
"clientName": "Acme Ltd",
"invoiceNumber": "INV-2026-001",
"date": "2026-06-19",
"total": 249.9
}

This is the recommended mode for scripts, scheduled jobs, and repeatable automation.


JSON Payload from Standard Input

Use --payload-stdin to read JSON from standard input:

cat invoice-data.json | eledoctl documents generate TEMPLATE_ID \
--payload-stdin \
--output invoice.pdf

This is useful when another command produces the JSON payload:

generate-invoice-json | eledoctl documents generate TEMPLATE_ID \
--payload-stdin \
--output invoice.pdf

Standard input works well in Unix pipelines and CI/CD jobs.


Input Priority

If a JSON payload is provided, it takes precedence over simple fields.

This means that when you use one of these options:

  • --payload
  • --payload-file
  • --payload-stdin

the command uses the JSON payload as the document data.

Simple fields provided with --add-field are intended for simple field mode. Do not mix both modes unless you explicitly want the JSON payload to be the source of truth.

Recommended usage:

eledoctl documents generate TEMPLATE_ID \
--add-field clientName="Acme Ltd" \
--output document.pdf

or:

eledoctl documents generate TEMPLATE_ID \
--payload-file data.json \
--output document.pdf

Avoid combining them in the same command.


Output File

Use --output to choose where the generated PDF should be saved:

eledoctl documents generate TEMPLATE_ID \
--payload-file data.json \
--output result.pdf

If the command succeeds, the PDF is written to the selected file.

The output path can be relative:

--output invoice.pdf

or absolute:

--output /opt/eledo/output/invoice.pdf

Example: Generate an Invoice

eledoctl documents generate TEMPLATE_ID \
--add-field clientName="Acme Ltd" \
--add-field invoiceNumber="INV-2026-001" \
--add-field total="249.90" \
--output invoice.pdf

This is the simplest form of document generation.


Example: Generate a PDF from JSON

Create data.json:

{
"clientName": "Acme Ltd",
"invoiceNumber": "INV-2026-001",
"date": "2026-06-19",
"items": [
{
"name": "Consulting",
"quantity": 1,
"price": 249.9
}
]
}

Then run:

eledoctl documents generate TEMPLATE_ID \
--payload-file data.json \
--output invoice.pdf

This mode is better when your document data is generated by another system.


Example: Use eledoctl in a Shell Script

#!/usr/bin/env bash
set -euo pipefail

TEMPLATE_ID="your-template-id"

eledoctl documents generate "$TEMPLATE_ID" \
--payload-file data.json \
--output document.pdf

This allows you to integrate Eledo into your own tools and automation scripts.


Example: Run from cron

You can use eledoctl in scheduled jobs.

Example cron entry:

0 7 * * * /usr/local/bin/eledoctl documents generate TEMPLATE_ID --payload-file /opt/eledo/daily-report.json --output /opt/eledo/out/daily-report.pdf

This example generates a PDF every day at 07:00.

Make sure the environment running the cron job has access to the same eledoctl configuration that was created with eledoctl login.


Troubleshooting

If document generation fails:

  • run eledoctl profile to verify authentication
  • run eledoctl templates to confirm that the template is available
  • check that the template ID is correct
  • verify that your JSON payload is valid JSON
  • make sure the output directory exists and is writable
  • try a simple --add-field example first to confirm that generation works

If the generated document is missing values, check that the field names in your payload match the fields expected by the Eledo template.

Eledo attempts to generate a document even when some fields are missing. Missing fields remain empty in the generated PDF.