Auto Convert Webpages to PDF and Route by Category

Oct 31, 2025·5 Minutes Read
(Using PDF.co + Google Sheets + Google Drive in n8n)

What You’ll Have When Done

A fully automated system that watches a Google Sheet for new webpage entries, converts each listed webpage to PDF via PDF.co, and then routes the generated PDF to the correct Google Drive folder based on its category (legal, docs, or blog). Each PDF is neatly named from your sheet’s Slug field and saved in the matching Drive folder for instant access and archiving.

Prerequisites

Before you begin, make sure you have:

  1. A PDF.co API KeyGet one here
  2. A connected Google Drive and Google Sheets OAuth2 credential in n8n
  3. An n8n instance (Cloud or Self-hosted)
  4. A Google Sheet structured as below
  5. Three destination folders in Google Drive:
Google Sheets Structure
Google Sheets Structure

Quick Start Options

Option A – I Want It Working Now

  1. Import this workflow JSON into n8n.
  2. Connect your Google Sheets and Google Drive accounts.
  3. Add your PDF.co API key in the PDF.co node.
  4. Update the Google Sheets Trigger with your sheet ID.
  5. Verify the three Drive folder IDs in the Code node.
  6. Add one test row in your sheet and watch the PDF appear in the correct folder!

Option B – I Want to Build It Step by Step

Follow the detailed 5-step guide below.

Sample Google Sheet Structure

Sample Google Sheet Structure
Sample Google Sheet Structure

What This Automation Does (Overview)

  1. Monitors your Google Sheet for new webpage entries.
  2. Determines the correct Google Drive folder ID from the sheet’s Section column.
  3. Converts each webpage URL to a PDF file using PDF.co’s “PDF from URL” endpoint.
  4. Downloads the generated PDF.
  5. Uploads it to the matching Drive folder (legal/docs/blog).
  6. Optionally updates your Google Sheet with a link to the finished PDF.

Step 1: Monitor Google Sheets for New Webpage Rows

What Happens Here

The workflow triggers automatically whenever a new row is added to your sheet, passing the row’s details (URL, Page Name, Slug, Section, etc.) downstream.

Node Used

Google Sheets Trigger

Settings/Value

  • Event: Row Added
  • Spreadsheet ID:your sheet ID (e.g., 1c3SGw-ndxVdUosIopB3E32Cqlku2enGdcwRfbY9eAnQ)
  • Sheet Name:Sheet1
  • Polling Interval: Every minute (adjust as needed)

Success Looks Like:

As soon as you add a new row, the workflow fires with all the sheet columns available as JSON fields.

Step 2: Assign the Correct Google Drive Folder Based on Section

What Happens Here

We use a small JavaScript “Code” node to read the Section column (e.g. docs, legal, blog) and attach the correct Drive folder ID so the Upload node knows where to save the PDF.

Node Used

Code

// Map each Section name to its Google Drive folder ID

const map = {

legal: '1CpeZggbkVKp-mT1_QKPKs5k7KerxV7BL',

blog: '1vB02cTyzypNgL2xDzuHpfDGfEvo-T4y0',

docs: '1EPuJSQV7aAfaZtdf_81toJrn8_AUAWdf',

};

// Normalize text (trim + lowercase)

function normSection(val) {

return String(val ?? '')

.trim()

.toLowerCase();

}

// Loop through incoming items

return items.map(it => {

const raw = it.json.Section ?? it.json.section;

const section = normSection(raw);

it.json.driveFolderId = map[section] || map.legal; // default fallback

it.json._sectionRaw = raw; // debug info

it.json._sectionNorm = section; // debug info

return it;

});

What This Code Does

  1. Defines a simple JavaScript object map linking each category to its Drive folder ID.
  2. Reads the “Section” value from the Google Sheet.
  3. Normalizes it to lowercase (so “Docs” = “docs”).
  4. Adds a new field driveFolderId to each item for the next node.

Success Looks Like:

Every incoming item now carries driveFolderId = the correct folder ID for its section.

Step 3: Convert Webpage URL → PDF (URL output)

What happens: We ask PDF.co to render the webpage into a PDF. PDF.co returns a temporary URL to the generated file (not binary yet).

Node: PDF.co App (native) → Operation: URL/HTML to PDF

  • URL: ={{ $json.URL }}
  • Advanced / File Name: ={{ $json.Slug }}
  • Orientation: ={{ $json.Orientation || "Portrait" }}
  • (Return type): leave as default URL output (this node returns a JSON with a url field)

This calls PDF.co API → PDF from URL behind the scenes.

Step 4: Download the PDF as Binary (GET)

What happens: We take the url from the PDF.co node and download it so we have a binary file to upload to Drive.

Node: HTTP Request

  • Method: GET
  • URL: ={{ $json.url }}
  • Response: File
  • Binary Property: data

File Name: ={{ $json.Slug }}.pdf

Success looks like: The node now outputs a binary property named data which contains the PDF bytes (ready for upload).

Step 5: Upload the Binary PDF to the Correct Drive Folder

What happens: We upload the binary PDF produced by the HTTP node into the mapped Drive folder (driveFolderId), keeping your naming scheme.

Node: Google Drive → Upload File

  • Binary Property: data
  • File Name: ={{ $json.Slug }}.pdf
  • Use Folder ID: ON
  • Folder ID: ={{ $json.driveFolderId }}

What This Does: Uploads each generated PDF to its respective folder:

  • legalsite-archive/legal/
  • docssite-archive/docs/
  • blogsite-archive/blog/

Success Looks Like: Within seconds, the PDF appears inside the correct Drive folder.

Step 6: Bonus (Recommended): Add a “Status + Link” Update Back to the Sheet

Columns and Expressions

  • PDF Link: ={{$json["webViewLink"]}}
  • Status: "Success"

This gives you instant visibility right inside your sheet.

Congrats!

You’ve built a hands-off system that turns webpage URLs from Google Sheets into properly filed PDF archives in Google Drive — categorized by section automatically.

Real Example

Real example

What Happens

  1. The Google Sheets Trigger detects the new row.
  2. The Code node reads docs and assigns the Drive folder ID 1EPuJSQV7aAfaZtdf_81toJrn8_AUAWdf.
  3. PDF.co converts the MDN page to PDF.

Google Drive uploads the file as: mdn-js-guide.pdf

  1. into site-archive/docs/

Check your Drive folder — the PDF is there instantly!

Built Something Cool?

Share your automation success with the community and tag @pdfdotco — we love seeing creative n8n + PDF.co workflows!

Related Tutorials

See Related Tutorials