Pandoc Md To icon

Pandoc Md To

Pandoc Markdown to PDF or docx

Overview

This node converts Markdown documents into either PDF or DOCX formats using the Pandoc command-line tool. It is useful when you need to transform Markdown content stored as binary data into widely used document formats for sharing, printing, or further editing.

Typical use cases include:

  • Generating PDF reports from Markdown notes.
  • Creating DOCX files from Markdown for collaboration in word processors.
  • Automating document format conversions within workflows.

The node supports specifying a reference DOCX file to control styling when converting to DOCX and allows passing additional custom options to the Pandoc command.

Properties

Name Meaning
Binary Property Name of the binary property containing the Markdown file to convert.
Reference Docx Name of the binary property containing a DOCX file to use as a style reference (only for DOCX output).
To Format Output format for the document. Options: PDF, DOCX.
Additional Options Extra command-line options to pass to Pandoc for advanced customization.

Output

The node outputs an array of items where each item contains:

  • json: The original JSON data from the input item.
  • binary: An object with one property named after the input binary property, containing:
    • data: Base64-encoded content of the converted file.
    • mimeType: MIME type corresponding to the output format (application/pdf for PDF, application/vnd.openxmlformats-officedocument.wordprocessingml.document for DOCX).
    • fileName: The original filename with the extension changed to .pdf or .docx accordingly.

No other output fields are added. If the conversion fails and "Continue On Fail" is enabled, the output will contain error details in the JSON part.

Dependencies

  • Requires Pandoc installed and accessible in the system's PATH.
  • Uses Node.js standard modules such as fs/promises, path, child_process.
  • No internal n8n credential types are required, but the node expects binary data input.

Troubleshooting

  • Common issues:

    • Missing binary data in the specified property will cause an error.
    • Pandoc not installed or not found in PATH will result in execution errors.
    • Incorrect additional options may cause Pandoc to fail.
    • Reference DOCX property missing or invalid when specified.
  • Error messages:

    • "No binary data found in property \"<propertyName>\"": Check that the input item contains the binary data under the given property name.
    • "Pandoc error: <error message>": Indicates Pandoc failed; verify the command options and input file validity.
    • "Output file does not exist": Conversion did not produce output; possibly due to Pandoc failure.
  • Resolutions:

    • Ensure the input binary property names are correct.
    • Confirm Pandoc is installed and accessible.
    • Validate any additional options passed to Pandoc.
    • Provide a valid reference DOCX file if using that option.

Links and References

Discussion