Compress Google Drive PDFs on arrival with pdfRest and n8n

Turn incoming PDFs into compressed copies automatically. Import this n8n workflow, connect your Google Drive and pdfRest credentials, and choose your folders.
Share this page

Google Drive + pdfRest + n8n

From incoming file to compressed PDF

A PDF arrives in your Google Drive folder. n8n downloads it, sends it to pdfRest for compression, and saves the processed copy to your chosen folder. Connect the steps visually, runs automatically, with no custom PDF-processing code required.

Requires self-hosted n8n + pdfRest API key. Cloud Starter outputs include watermarks or text redactions.

One file in. A compressed copy out.

  1. Watch the folder

    Checks your input folder every minute for new PDFs.

  2. Download the PDF

    Retrieves the file into n8n while preserving the original.

  3. Compress with pdfRest

    Applies medium compression and downloads the result.

  4. Save to Google Drive

    Saves the compressed copy to your chosen output folder.

For example, report.pdf becomes report-compressed.pdf. The source file stays in its original folder. File-size reduction depends on the document; an already optimized PDF may not become smaller.

Before you start

  • A running self-hosted n8n instance with @pdfrest/n8n-nodes-pdfrest installed.
  • A Google Drive credential in n8n with access to your input and output folders.
  • A pdfRest Cloud API key.
  • Two separate Google Drive folders: one for incoming PDFs and one for compressed results.

The main setup guide covers running n8n with Node.js or Docker and installing the community node. If Google Drive is not connected yet, self-hosted n8n uses custom Google OAuth credentials. Follow the linked guide to enable the Drive API, configure OAuth, and connect your account.

Use a PDF-only input folder and a different output folder. This template watches new files without a PDF filter. Keeping the folders separate prevents the uploaded result from triggering the same workflow again.

Import the connected workflow

  1. Download pdfrest-google-drive-compress-workflow.json using the gold button above.
  2. Open your self-hosted n8n instance and create a new workflow.
  3. Open the three-dot menu in the workflow editor and choose Import from File.
  4. Select the downloaded JSON. You should see four connected nodes and a setup note.
  5. Save the workflow, then connect your credentials and choose your folders before publishing or activating it.

The JSON contains no credentials or account-specific folder IDs. Importing it does not connect your accounts or start scheduled processing.

Connect your accounts and folders

1. Choose the folder to watch

PDF-only input folderGoogle Drive Trigger

Open Google Drive Trigger and select your Google Drive credential. Choose your incoming-PDF folder. Keep the event set to File Created and polling set to Every Minute.

2. Connect the download

New file IDDownload fileBinary field: data

Open Download file and select the same Google Drive credential. The file ID expression is already connected to the trigger. Keep the output binary field set to data.

3. Connect pdfRest Cloud

PDF in dataCompress PDF · MediumOutput in data

Open pdfRest API Toolkit and select or create your pdfRest API credential for Cloud.

Copy your API key from the pdfRest dashboard. In the n8n credential, choose the US or EU API Base URL, enter your key, and save the credential. Keep the key in n8n’s credential store, not in the workflow JSON.

The template selects Compress PDF, Input File, and Medium compression. Both file-data fields are data, and Download Output Files is enabled so the next node receives the processed PDF.

4. Choose where the result goes

Compressed PDFUpload compressed PDFSeparate output folder

Open Upload compressed PDF and select your Google Drive credential. Choose your destination drive and compressed-output folder. The input field is data. The filename expression removes the original .pdf extension and adds -compressed.pdf.

Test one PDF, then let it run

  1. Add a sample PDF to the input folder.
  2. Run a manual test in n8n. The Drive trigger retrieves a recent matching event; an empty folder can return no matching data.
  3. Check that the download contains binary data, pdfRest completes, and the upload creates a file in the output folder.
  4. Open the result and compare its size and appearance with the source.
  5. Save and publish or activate the workflow, depending on your n8n version. Add a new PDF to confirm the scheduled flow runs.

Keep n8n running for the one-minute polling schedule to work. This template processes new-file events; it does not automatically backfill every PDF already in the folder. Re-running a test can upload another copy of the result.

Questions

Why is the pdfRest node missing after import?

Install @pdfrest/n8n-nodes-pdfrest through Settings → Community Nodes in self-hosted n8n, then reopen the workflow. This template requires that community node.

Why does the upload say there is no file data?

Check that the Drive download uses data, that the pdfRest input and output fields are data, and that Download Output Files is enabled. The upload must also read data.

Why does nothing happen when I add a file?

Check the watched folder, Google Drive credential access, and whether the workflow is published or active. Leave n8n running and allow for the one-minute polling interval. Review the execution history for errors.

Can I use a folder with other file types?

Use a PDF-only folder for this version. For mixed files, add a filter before the download and pdfRest steps to pass only PDFs.

Where are my documents processed?

n8n downloads the source from Google Drive and sends it to pdfRest Cloud in the US or EU, depending on the API Base URL selected in your credential. The compressed PDF returns through n8n and is saved to your chosen Google Drive folder.

Make compression part of the workflow.

Import the template, connect your accounts, and test your first PDF.

Generate a self-service API Key now!
Create your FREE API Key to start processing PDFs in seconds, only possible with pdfRest.