Compress PDFs

The Compress Pages from PDF node allows you to compress PDF files using n8n. You can further extend this workflow to convert HTML or code into a PDF, compress the generated PDF, and return it as a binary response.
Compress PDFs with n8n
Compress PDFs with n8n

Compress PDFs

  1. Open a new n8n workflow and add a Webhook node (or use Request HTML or Code if you want to fetch stored PDFs).
  2. Add the Compress Pages from PDF (customJS) node from the PDF Toolkit.
  3. Connect the incoming PDF file to this node.
  4. In the node settings, choose which PDF pages to compress.
  5. Configure the output settings:
    • Set the file name for the compressed PDF.
    • Define the storage location (e.g., with Read/Write Files from Disk).
  6. (Optional) Add a Respond to Webhook node to return the compressed PDF directly to the requester.

n8n workflow template: Convert HTML to PDF and compress files

This workflow template:

  1. Converts the requested HTML to PDF.
  2. Compresses the PDF file.
  3. Handles URLs pointing to PDF files if they exceed 6MB.
  4. Compresses the PDF pages.
Use this template