docx-to-pdf

n8n community node to convert DOCX/Word documents to PDF using LibreOffice. Preserves all formatting, images, tables, and layout with perfect fidelity.

Package Information

Released: 9 mo ago
Downloads: 8 weekly / 32 monthly
Latest Version: 1.0.2
Author: Daniel Sanchez

Documentation

n8n DOCX to PDF Node

Convert Word documents (DOCX) to PDF using LibreOffice. Preserves all formatting, images, tables, headers, footers, and layout with perfect fidelity.

npm version
License: MIT

Features

✅ Perfect Quality - Uses LibreOffice for professional-grade conversions
✅ Preserves Everything - Images, tables, formatting, headers, footers
✅ Free Forever - No API costs, no usage limits
✅ Works Offline - No internet connection required
✅ Batch Processing - Convert multiple files in one workflow
✅ Flexible Output - Custom filenames, keep original files

Prerequisites

LibreOffice must be installed on your system.

Ubuntu/Debian

sudo apt-get update
sudo apt-get install -y libreoffice

macOS

brew install libreoffice

Docker

If running n8n in Docker, use this Dockerfile:

FROM n8nio/n8n:latest

USER root
RUN apt-get update && \
    apt-get install -y libreoffice && \
    apt-get clean && \
    rm -rf /var/lib/apt/lists/*

USER node

Build and run:

docker build -t n8n-with-libreoffice .
docker run -it --rm \
  -p 5678:5678 \
  -v ~/.n8n:/home/node/.n8n \
  n8n-with-libreoffice

Docker Compose

Add to your docker-compose.yml:

services:
  n8n:
    image: n8nio/n8n:latest
    user: root
    environment:
      - N8N_PROTOCOL=http
      - N8N_HOST=localhost
      - N8N_PORT=5678
    ports:
      - 5678:5678
    volumes:
      - ~/.n8n:/home/node/.n8n
    command: >
      sh -c "apt-get update && 
             apt-get install -y libreoffice && 
             su node -c 'n8n start'"

Installation

In n8n (GUI)

  1. Go to Settings > Community Nodes
  2. Click Install
  3. Enter: n8n-nodes-docx-to-pdf
  4. Click Install

Manual Installation

cd ~/.n8n/custom
npm install n8n-nodes-docx-to-pdf

From Source

# Clone or download this repository
cd n8n-nodes-docx-to-pdf
npm install
npm run build

# Link to n8n
npm link
cd ~/.n8n/custom
npm link n8n-nodes-docx-to-pdf

Usage

Basic Workflow

[Read Binary Files] → [DOCX to PDF] → [Write Binary Files]

Configuration

Input Binary Property
Name of the binary property containing your DOCX file (default: data)

Output Binary Property
Name of the binary property where the PDF will be stored (default: data)

Output Filename (optional)
Custom filename for the PDF. If empty, uses the original filename with .pdf extension.

Example: Google Drive Integration

[Google Drive - Download] 
    ↓
[DOCX to PDF] 
    ↓
[Google Drive - Upload]

Example: Batch Email Attachments

[Gmail Trigger - New Email] 
    ↓
[Extract Attachments] 
    ↓
[Filter: .docx files]
    ↓
[DOCX to PDF] 
    ↓
[Send Email - with PDF]

Example: Webhook to PDF

[Webhook] - receives DOCX upload
    ↓
[DOCX to PDF]
    ↓
[Return PDF to client]

Options

Keep Original Binary

Enable this option to keep the original DOCX file alongside the PDF in the binary data. Useful when you need both versions.

Output Data

The node adds these properties to the JSON output:

{
  "filename": "document.pdf",
  "originalFilename": "document.docx",
  "fileSize": 245680,
  "mimeType": "application/pdf"
}

Error Handling

The node will throw an error if:

  • LibreOffice is not installed
  • The input file is corrupted or not a valid DOCX
  • The system runs out of memory

Enable Continue On Fail in the node settings to handle errors gracefully in production.

Performance

  • Small files (<1MB): ~1-2 seconds
  • Medium files (1-5MB): ~2-5 seconds
  • Large files (>5MB): ~5-15 seconds

Performance depends on document complexity and server resources.

Troubleshooting

"LibreOffice not found" error

Check if LibreOffice is installed:

which libreoffice
# or
which soffice

If not installed, follow the installation instructions above.

Docker users:
Make sure your Dockerfile includes LibreOffice installation. Rebuild your image:

docker build -t n8n-with-libreoffice .

Node doesn't appear in n8n

  1. Restart n8n completely
  2. Clear browser cache
  3. Check if the node is installed:
    ls ~/.n8n/custom/node_modules/n8n-nodes-docx-to-pdf
    

Poor conversion quality

LibreOffice provides the best quality available. If you're experiencing issues:

  • Make sure you're using a recent version of LibreOffice
  • Check if the DOCX file opens correctly in LibreOffice manually
  • Some very complex documents may need adjustment

Memory issues with large files

For very large documents (>50MB), increase Node.js memory:

export NODE_OPTIONS="--max-old-space-size=4096"
n8n start

Supported File Types

  • .docx (Word 2007 and later)
  • .doc (Word 97-2003) - also supported
  • .odt (OpenDocument Text) - also supported

Comparison with Alternatives

Solution Quality Cost Setup Dependencies
This Node (LibreOffice) ⭐⭐⭐⭐⭐ Free Medium LibreOffice
Cloud APIs (ConvertAPI, etc.) ⭐⭐⭐⭐⭐ Paid Easy None
Pure JS libraries ⭐⭐ Free Easy None

Development

# Install dependencies
npm install

# Build
npm run build

# Watch mode
npm run dev

# Lint
npm run lint

# Format
npm run format

Contributing

Contributions are welcome! Please open an issue or submit a pull request.

License

MIT

Support

Credits

Built with:


Made with ❤️ for the n8n community

Discussion