n8n-nodes-docx-to-pdf
v1.0.2
Published
n8n community node to convert DOCX/Word documents to PDF using LibreOffice. Preserves all formatting, images, tables, and layout with perfect fidelity.
Maintainers
Readme
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.
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 libreofficemacOS
brew install libreofficeDocker
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 nodeBuild and run:
docker build -t n8n-with-libreoffice .
docker run -it --rm \
-p 5678:5678 \
-v ~/.n8n:/home/node/.n8n \
n8n-with-libreofficeDocker 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)
- Go to Settings > Community Nodes
- Click Install
- Enter:
n8n-nodes-docx-to-pdf - Click Install
Manual Installation
cd ~/.n8n/custom
npm install n8n-nodes-docx-to-pdfFrom 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-pdfUsage
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 sofficeIf 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
- Restart n8n completely
- Clear browser cache
- 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 startSupported 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 formatContributing
Contributions are welcome! Please open an issue or submit a pull request.
License
MIT
Support
Credits
Built with:
Made with ❤️ for the n8n community
