@cafeasp/n8n-nodes-pdf-to-pdf
v0.1.0
Published
n8n node to re-save PDF files to fix missing page dimensions and other issues
Downloads
12
Maintainers
Readme
n8n PDF to PDF Node
An n8n community node that re-saves PDF files to fix missing page dimensions and other structural issues. This node processes PDF binary data and outputs a properly formatted PDF with corrected metadata.
Why This Node?
Some PDF files may have missing or incorrect page dimensions, which can cause issues when:
- Displaying PDFs in viewers
- Converting PDFs to other formats
- Processing PDFs with other tools
- Printing documents
This node loads the PDF, ensures all pages have proper dimensions, and saves it as a new properly formatted PDF file.
Installation
Follow the installation guide in the n8n community nodes documentation.
Manual Installation
- Install the package in your n8n installation:
npm install @cafeasp/n8n-nodes-pdf-to-pdf- Restart n8n to load the new node.
Development Installation
- Clone this repository:
git clone https://github.com/cafeasp/n8n-pdf-to-pdf.git
cd n8n-pdf-to-pdf- Install dependencies:
npm install- Build the project:
npm run build- Link your node to n8n:
Linux/Mac:
npm link
cd ~/.n8n/custom
npm link @cafeasp/n8n-nodes-pdf-to-pdfWindows (PowerShell - Run as Administrator):
npm link
cd $env:USERPROFILE\.n8n\custom
npm link @cafeasp/n8n-nodes-pdf-to-pdfWindows (Command Prompt - Run as Administrator):
npm link
cd %USERPROFILE%\.n8n\custom
npm link @cafeasp/n8n-nodes-pdf-to-pdf- Restart n8n to load the new node.
Usage
Node Configuration
The node has the following parameters:
- Binary Property: The name of the binary property containing the input PDF file (default: "data")
- Output Binary Property: The name of the binary property where the re-saved PDF will be stored (default: "data")
- Options:
- File Name: Optional custom file name for the output PDF
Example Workflow
- Read a PDF file using the "Read Binary File" node or receive it from an HTTP request
- Add the "PDF to PDF" node
- Configure the binary property names (or use defaults)
- The node will output the re-saved PDF with proper page dimensions
- Use the output with other nodes (save to file, send via email, upload to cloud storage, etc.)
What the Node Does
- Accepts a PDF file as binary input
- Loads the PDF using pdf-lib
- Processes each page to ensure dimensions are properly set
- Saves the PDF with corrected metadata
- Returns the new PDF as binary output
Development
Prerequisites
- Node.js (v14 or higher)
- npm or yarn
- n8n installed (for testing)
Scripts
npm run build- Build the project and copy iconsnpm run dev- Watch mode for developmentnpm run format- Format code with Prettiernpm run lint- Lint the codenpm run lintfix- Auto-fix linting issues
Technical Details
This node uses the pdf-lib library to:
- Load PDF documents
- Access and process page dimensions
- Save modified PDFs with proper structure
Compatibility
- n8n version: 0.198.0 or higher
- n8n nodes API version: 1
License
MIT
Author
Victor Pacheco
- Email: [email protected]
- GitHub: @cafeasp
Support
If you encounter any issues or have questions:
- Open an issue on GitHub
- Check the n8n community forum
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
- Start or restart(control c) n8n:
npm run build
npx n8nYour node should now appear in the nodes panel
Customization
- Update package.json: Change the
name,description,author, andrepositoryfields - Rename files: Rename
Example.node.tsand the credential file to match your integration - Update the node: Modify the node properties, operations, and logic in the
.node.tsfile - Update credentials: Adjust the credential properties to match your API requirements
- Replace icon: Replace
example.svgwith your own icon - Update n8n config: Update the
n8nsection in package.json to reflect your renamed files
Publishing
Before publishing to npm:
- Update package.json with your package details
- Ensure your package name starts with
n8n-nodes- - Add
n8n-community-node-packageto keywords in package.json - Build the project:
npm run build - Publish:
npm publish
Resources
License
MIT
