PDF Generator icon

PDF Generator

Convert text (including markdown) to PDF documents

Overview

This node converts text content, including markdown-formatted text, into a PDF document. It is useful for automating the generation of PDF reports, documentation, invoices, or any textual content that benefits from rich formatting and needs to be distributed or archived as a PDF file.

Typical use cases include:

  • Creating styled PDF reports from markdown notes.
  • Generating printable documents with custom page sizes and fonts.
  • Automating export of markdown-based content into shareable PDFs.

For example, you can input markdown text with headers, bullet points, bold and italic styles, and the node will produce a formatted PDF file named as specified.

Properties

Name Meaning
Text Content The markdown-formatted text to convert into a PDF document. Supports headers, lists, bold, italic, code blocks, etc.
Output Filename The filename for the generated PDF file (e.g., "my-document.pdf").
Page Options Page layout settings:
- Page Size: Choose from A4, Letter, Legal, Tabloid.
- Margins (PT): Page margins in points (72 points = 1 inch).
Font Options Font styling options:
- Base Font Size: Default font size for body text.
- Line Height: Line height multiplier (e.g., 1.4 for 1.4x spacing).
- Font Family: Choose from Helvetica, Times Roman, Courier.

Output

The node outputs an array with one item per input. Each output item contains:

  • json:
    • success: Boolean indicating if PDF generation succeeded.
    • filename: The name of the generated PDF file.
    • size: The size of the generated PDF in bytes.
  • binary:
    • data: The PDF file data encoded as a base64 string.
    • mimeType: Always "application/pdf".
    • fileName: The output filename as specified in the input.

This allows downstream nodes to access the PDF file either as binary data for saving or sending, or metadata about the file.

Dependencies

  • Uses the pdfkit library to generate PDF documents.
  • No external API or service dependencies.
  • Requires no special environment variables or credentials.

Troubleshooting

  • Missing Text Content: If the "Text Content" property is empty, the node throws an error stating that text content is required.
  • PDF Generation Errors: Any internal errors during PDF creation emit a message like "PDF generation failed: ...". This usually indicates invalid input or resource constraints.
  • Continue on Fail: If enabled, the node will continue processing subsequent items even if one fails, returning error details in the output JSON.

To resolve issues:

  • Ensure valid markdown text is provided.
  • Check page size and margin values are reasonable.
  • Verify font options are correctly selected.

Links and References

Discussion