8
n8n 中文网amn8n.com

批量PDF转Markdown转换(Google Drive与LLM解析)

中级

这是一个Content Creation, Multimodal AI领域的自动化工作流,包含 8 个节点。主要使用 If, Set, Code, Slack, GoogleDrive 等节点。 使用Google Drive和LLM驱动的解析进行批量PDF转Markdown转换

前置要求
  • Slack Bot Token 或 Webhook URL
  • Google Drive API 凭证
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "meta": {
    "instanceId": "placeholder"
  },
  "nodes": [
    {
      "id": "info-note",
      "name": "工作流信息",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        250,
        150
      ],
      "parameters": {
        "content": "## 批量 PDF 转换器"
      },
      "typeVersion": 1
    },
    {
      "id": "google-drive",
      "name": "Google Drive - 列出 PDF 文件",
      "type": "n8n-nodes-base.googleDrive",
      "notes": "List all PDFs from specified folder",
      "position": [
        450,
        300
      ],
      "parameters": {
        "fileId": "={{ $json.folderId }}",
        "operation": "list"
      },
      "typeVersion": 1
    },
    {
      "id": "filter-pdfs",
      "name": "仅筛选 PDF 文件",
      "type": "n8n-nodes-base.if",
      "position": [
        650,
        300
      ],
      "parameters": {
        "conditions": {
          "string": [
            {
              "value1": "={{ $json.mimeType }}",
              "value2": "application/pdf"
            }
          ]
        }
      },
      "typeVersion": 1
    },
    {
      "id": "pdfvector-convert",
      "name": "PDF Vector - 转换为 Markdown",
      "type": "n8n-nodes-pdfvector.pdfVector",
      "notes": "Convert each PDF to Markdown",
      "position": [
        850,
        300
      ],
      "parameters": {
        "useLlm": "auto",
        "resource": "document",
        "operation": "parse",
        "documentUrl": "={{ $json.webViewLink }}"
      },
      "typeVersion": 1
    },
    {
      "id": "prepare-output",
      "name": "准备输出",
      "type": "n8n-nodes-base.code",
      "position": [
        1050,
        300
      ],
      "parameters": {
        "functionCode": "const fileName = $json.name.replace('.pdf', '.md');\nconst content = $json.content;\nconst metadata = {\n  originalFile: $json.name,\n  convertedAt: new Date().toISOString(),\n  pageCount: $json.pageCount || 'unknown',\n  credits: $json.creditsUsed || 0\n};\n\nreturn {\n  fileName,\n  content,\n  metadata\n};"
      },
      "typeVersion": 1
    },
    {
      "id": "save-markdown",
      "name": "保存 Markdown 文件",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        1250,
        300
      ],
      "parameters": {
        "name": "={{ $json.fileName }}",
        "content": "={{ $json.content }}",
        "parents": [
          "{{ $json.outputFolderId }}"
        ],
        "operation": "upload"
      },
      "typeVersion": 1
    },
    {
      "id": "summary-stats",
      "name": "转换摘要",
      "type": "n8n-nodes-base.set",
      "position": [
        1450,
        300
      ],
      "parameters": {
        "values": {
          "string": [
            {
              "name": "summary",
              "value": "=Converted {{ $items().length }} PDFs to Markdown\nTotal credits used: {{ $items().reduce((sum, item) => sum + (item.json.metadata.credits || 0), 0) }}"
            }
          ]
        }
      },
      "typeVersion": 1
    },
    {
      "id": "notify-complete",
      "name": "发送通知",
      "type": "n8n-nodes-base.slack",
      "position": [
        1650,
        300
      ],
      "parameters": {
        "message": "=Batch Conversion Complete!\n\n{{ $json.summary }}\n\nFiles saved to Google Drive.",
        "additionalFields": {}
      },
      "typeVersion": 1
    }
  ],
  "connections": {
    "Prepare Output": {
      "main": [
        [
          {
            "node": "Save Markdown Files",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter PDFs Only": {
      "main": [
        [
          {
            "node": "PDF Vector - Convert to Markdown",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Conversion Summary": {
      "main": [
        [
          {
            "node": "Send Notification",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Save Markdown Files": {
      "main": [
        [
          {
            "node": "Conversion Summary",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Drive - List PDFs": {
      "main": [
        [
          {
            "node": "Filter PDFs Only",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "PDF Vector - Convert to Markdown": {
      "main": [
        [
          {
            "node": "Prepare Output",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。

这个工作流适合什么场景?

中级 - 内容创作, 多模态 AI

需要付费吗?

本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。

工作流信息
难度等级
中级
节点数量8
分类2
节点类型7
难度说明

适合有一定经验的用户,包含 6-15 个节点的中等复杂度工作流

作者
PDF Vector

PDF Vector

@pdfvector

A fully featured PDF APIs for developers - Parse any PDF or Word document, extract structured data, and access millions of academic papers - all through simple APIs.

外部链接
在 n8n.io 查看

分享此工作流