Consolidated Invoice Distribution Workflow

4 Minutes Read

What You'll Have When Done: A fully automated system that monitors your Google Drive for consolidated invoices, extracts customer data, and generates separate redacted PDF invoices for each customer with only their information visible.

Prerequisites

Before beginning:

  1. Install the PDF.co community node in n8n: n8n-nodes-pdfco
  2. Reload the n8n editor.
  3. Create a PDF.co credential in n8n.
  4. Connect Google Drive and select the input and output folders.
  5. Create a Document Parser template for the consolidated invoice and copy its Template ID.

Quick Start Options

Option A: I Want It Working Now

  1. Import this workflow template → Download JSON File
  2. Connect your Google Drive account in n8n
  3. Add your PDF.co API key to both HTTP Request nodes
  4. Configure your input folder for consolidated invoices
  5. Configure your output folder for redacted invoices
  6. Test with a sample consolidated invoice
  7. Activate and let it run

Option B: I Want to Build It Step-by-Step

Follow the 6-step guide below to create the automation from scratch.

What This Automation Does (Overview)

  • Monitors your Google Drive folder for new consolidated invoices
  • Extracts customer/item data from the invoice using the Document Parser
  • Identifies all unique customers in the consolidated invoice
  • Creates separate PDF copies for each customer with other customer data redacted
  • Stores each customer-specific invoice in your designated folder

Real Example: One invoice containing charges for Item 1, Item 2, Item 3, Item 4 → Get 4 separate PDFs where each shows only one item's data with all others blacked out. View Sample Files Here.

Step-by-Step Build Guide

Step 1: Monitor for New Consolidated Invoices

Node: Google Drive Trigger

Settings:

  • Trigger On: Changes Involving a Specific Folder
  • Folder to Watch: Select your designated barcode upload folder
  • Watch For: File Created

What This Does: Automatically detects when you upload a new consolidated invoice to your designated Google Drive folder and starts the distribution process.

Success Looks Like: The trigger activates immediately when a consolidated invoice is uploaded, capturing the file information and download link.

Important: Make sure the file sharing setting is set to “Anyone with the link” so that PDF.co can access the file.

Step 2: Extract Customer Data from Invoice

Node: PDF.co API

Configure the node as follows:

  • Credential: Select your PDF.co connection
  • Action: Document Parser
  • Source File URL: Map the Google Drive file URL: ={{ $json.webContentLink }}
  • Template ID: Enter the ID of the Document Parser template created for the consolidated invoice.

Run the node and confirm that it returns the invoice’s customer and line-item data.

The source file must be accessible to PDF.co. If the Google Drive URL is not publicly accessible, download the file and upload it with the PDF.co Upload File action first, then map the returned PDF.co URL into Document Parser.

Step 3: Generate Redaction Configurations

Node: Code (JavaScript)

JavaScript Code: Get The Code Here

What This Does: Processes the parsed invoice data to:

  • Identify all unique customers/items from the invoice
  • Create redaction instructions for each customer (specifying which OTHER customers' data should be hidden)
  • Generate regex patterns to find and blackout specific data rows

Key Logic Example: If invoice contains Item 1, Item 2, Item 3:

  • Item 1's copy: Hide Item 2 and Item 3 data
  • Item 2's copy: Hide Item 1 and Item 3 data
  • Item 3's copy: Hide Item 1 and Item 2 data

Success Looks Like: Each unique customer gets their own redaction configuration specifying exactly which data to hide from their personalized invoice.

Step 4: Create Redacted Customer Invoices

Node: PDF.co API

Configure the node as follows:

  • Credential: Select your PDF.co connection
  • Action: Search and Delete Text
  • Source File URL: ={{ $('Google Drive Trigger').item.json.webContentLink }}
  • Search Strings: Map the searchStrings value produced by the Code node.
  • Enable Regular Expressions: Yes
  • Pages: Leave blank to search every page
  • Output File Name: Map the customer-specific filename generated by the Code node
  • Custom Profiles: { 'usepatch': true, 'patchColor': '#000000', 'removeTextUnderPatch': true }

This removes the selected text and covers its former location with a black patch.

Step 5: Download the Processed Invoice

Node: HTTP Request

Settings:

  • Method: GET
  • URL: {{ $json.url }} (from the redaction step)
  • Response Format: File
  • Output Binary Field: data

What This Does: Downloads the newly created customer-specific invoice from PDF.co's servers so it can be saved to your Google Drive.

Success Looks Like: The redacted customer invoice is downloaded and ready for storage.

Step 6: Store Customer Invoice in Google Drive

Node: Google Drive → Upload File

Settings:

  • Input Data Field Name: data
  • File Name: Map the customer-specific filename
  • Parent Drive: My Drive
  • Parent Folder: Select the folder for the customer invoices

What This Does: Saves each customer-specific invoice to your designated Google Drive folder with clear naming for easy distribution.

Success Looks Like: Individual customer invoices appear in your output folder, each showing the complete invoice format with only relevant customer data visible.

Congrats! You've created a fully automated invoice distribution system that transforms consolidated billing into professional, privacy-compliant customer invoices. This system scales automatically and eliminates the manual work of creating separate customer invoices.

Built something cool with this workflow? Share it with us @pdfdotco

Related Tutorials

See Related Tutorials