pdf-to-pdf

n8n node to re-save PDF files to fix missing page dimensions and other issues

Package Information

Downloads: 1 weekly / 13 monthly
Latest Version: 0.1.0
Author: Victor

Documentation

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

  1. Install the package in your n8n installation:
npm install @cafeasp/n8n-nodes-pdf-to-pdf
  1. Restart n8n to load the new node.

Development Installation

  1. Clone this repository:
git clone https://github.com/cafeasp/n8n-pdf-to-pdf.git
cd n8n-pdf-to-pdf
  1. Install dependencies:
npm install
  1. Build the project:
npm run build
  1. Link your node to n8n:

Linux/Mac:

npm link
cd ~/.n8n/custom
npm link @cafeasp/n8n-nodes-pdf-to-pdf

Windows (PowerShell - Run as Administrator):

npm link
cd $env:USERPROFILE\.n8n\custom
npm link @cafeasp/n8n-nodes-pdf-to-pdf

Windows (Command Prompt - Run as Administrator):

npm link
cd %USERPROFILE%\.n8n\custom
npm link @cafeasp/n8n-nodes-pdf-to-pdf
  1. 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

  1. Read a PDF file using the "Read Binary File" node or receive it from an HTTP request
  2. Add the "PDF to PDF" node
  3. Configure the binary property names (or use defaults)
  4. The node will output the re-saved PDF with proper page dimensions
  5. Use the output with other nodes (save to file, send via email, upload to cloud storage, etc.)

What the Node Does

  1. Accepts a PDF file as binary input
  2. Loads the PDF using pdf-lib
  3. Processes each page to ensure dimensions are properly set
  4. Saves the PDF with corrected metadata
  5. 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 icons
  • npm run dev - Watch mode for development
  • npm run format - Format code with Prettier
  • npm run lint - Lint the code
  • npm 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

Support

If you encounter any issues or have questions:

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Start or restart(control c) n8n:
npm run build
npx n8n

Your node should now appear in the nodes panel

Customization

  1. Update package.json: Change the name, description, author, and repository fields
  2. Rename files: Rename Example.node.ts and the credential file to match your integration
  3. Update the node: Modify the node properties, operations, and logic in the .node.ts file
  4. Update credentials: Adjust the credential properties to match your API requirements
  5. Replace icon: Replace example.svg with your own icon
  6. Update n8n config: Update the n8n section in package.json to reflect your renamed files

Publishing

Before publishing to npm:

  1. Update package.json with your package details
  2. Ensure your package name starts with n8n-nodes-
  3. Add n8n-community-node-package to keywords in package.json
  4. Build the project: npm run build
  5. Publish: npm publish

Resources

License

MIT

Discussion