@hichamchar/n8n-nodes-pdflib
v0.4.1
Published
n8n community node for filling and manipulating PDF documents using pdf-lib. Perfect for generating tax receipts, invoices, and forms.
Maintainers
Readme
n8n PDF-lib Custom Node
A custom n8n node for working with PDF documents using the pdf-lib library. This node allows you to fill PDF forms, create new PDFs, and merge multiple PDFs directly in your n8n workflows.
🎯 Features
- Fill PDF Forms - Add text overlays to existing PDF documents with full positioning control
- Fill Form Fields - Fill actual interactive PDF form fields (text, checkboxes, radio buttons)
- Extract Form Fields - Discover all form fields, types, values, and properties from PDFs ✨ NEW in v0.4.0
- Add Images - Embed PNG and JPEG images into PDFs with positioning and rotation
- Create PDFs - Generate new PDF documents from scratch
- Merge PDFs - Combine multiple PDF files into one with support for multiple sources
- JavaScript Code Mode - Programmatically define fields using JavaScript code
- French Character Support - Full UTF-8 support for international characters
- Flexible Input - Works with URLs or binary data
- Customizable - Configure fonts, colors, positions, sizes, and rotations
📦 Installation
Follow the detailed instructions in SETUP.md to install this custom node in your n8n instance.
Quick Start:
cd ~
wget https://github.com/n8n-io/n8n-nodes-starter/archive/refs/heads/master.zip
unzip master.zip
mv n8n-nodes-starter-master n8n-nodes-pdflib
cd n8n-nodes-pdflib
# Clean up examples
rm -rf nodes/ExampleNode nodes/HttpBin credentials/*
# Copy the PDF-lib node files into nodes/PdfLib/
# Update package.json with the provided version
# Build and link
npm install
npm run build
npm link
# Link to n8n
cd ~/.n8n/custom
npm link n8n-nodes-pdflib
docker restart n8n🚀 Usage
Fill PDF Form
Perfect for filling tax receipts, invoices, or any form-based PDFs:
- Select Fill PDF Form operation
- Choose PDF source (URL or Binary Data)
- Add text fields with coordinates and styling
- Output as binary data
Example Use Case: French Tax Receipt (Reçu Fiscal)
- Load template PDF from URL
- Add donor name, address, amount, date
- Generate personalized receipt
Create PDF
Create new PDF documents from scratch:
- Select Create PDF operation
- Choose page size (A4, Letter, or Custom)
- Add text fields with positions and styling
- Output as binary data
Extract Form Fields ✨ NEW
Discover all form fields in a PDF before filling:
- Select Extract Form Fields operation
- Choose PDF source (URL or Binary Data)
- Get JSON output with all field information
Returns:
- Field names and types (text, checkbox, radio, dropdown, list, button, signature)
- Current values and properties
- Max lengths, options, read-only status
- PDF metadata (page count, title, author)
Perfect for:
- Finding exact field names before filling forms
- Validating PDF form structure
- Building dynamic form-filling workflows
- Documenting form fields
Merge PDFs
Combine multiple PDF files:
- Select Merge PDFs operation
- Add multiple PDF sources (URL or Binary Data)
- Get combined PDF as output
📋 Sample Workflow
A sample workflow for French tax receipts is included in sample-workflow.json. Import it into n8n to see the node in action.
The workflow:
- Takes donation data (name, address, amount, date)
- Fills a PDF template
- Saves the result
- Optionally emails it to the donor
🛠️ Files Included
nodes/PdfLib/PdfLib.node.ts- Main node implementationnodes/PdfLib/PdfLib.node.json- Node metadatanodes/PdfLib/logo-full.svg- PDF-lib logo iconpackage.json- Package configurationSETUP.md- Detailed setup instructionsPUBLISHING.md- Guide to publish to npmCHANGELOG.md- Version historysample-workflow.json- Example workflowREADME.md- This file
🔧 Configuration
Text Field Parameters
- Text - The text content to add
- X Position - Horizontal position from left (in points)
- Y Position - Vertical position from bottom (in points)
- Font Size - Text size (default: 12)
- Page Number - Which page to add text to (0-indexed)
- Color - Text color in hex format (e.g., #000000)
Coordinate System
PDFs use a coordinate system where:
- (0, 0) is at the bottom-left corner
- X increases to the right
- Y increases upward
- A4 page is approximately 595 x 842 points
🎨 Customization
You can extend this node by:
- Adding more PDF operations (rotate, extract, compress)
- Supporting more fonts (embed custom TTF fonts)
- Adding image support
- Creating credential support for authenticated sources
📚 Resources
🐛 Troubleshooting
Node doesn't appear:
- Verify npm link worked:
ls -la ~/.n8n/custom/node_modules - Check Docker logs:
docker logs n8n - Restart n8n:
docker restart n8n
Build errors:
- Delete node_modules and reinstall:
rm -rf node_modules package-lock.json && npm install - Ensure TypeScript is installed:
npm install -g typescript
PDF operations fail:
- Check URL accessibility from Docker container
- Verify coordinates are within page bounds
- Check n8n execution logs for details
📄 License
MIT
🤝 Contributing
This is a custom node for personal/organizational use. Feel free to modify and extend it for your needs!
✨ Advantages
✅ Permanent - Survives n8n updates
✅ Local - No external API dependencies
✅ Fast - Runs directly in n8n
✅ Flexible - Full control over PDF operations
✅ Reusable - Works across all workflows
✅ Team-Friendly - Easy for others to use
