PDF 转 Markdown API

将 PDF 文档转换为 Markdown 格式,支持自动图片提取

概述

PDF 转 Markdown API 可以将 PDF 文档转换为 Markdown 格式,支持自动图片提取和托管。 它使用统一的 JSON 请求格式,支持 URL 引用或 base64 编码的文档数据。

身份验证

API 支持以下身份验证方法:

  • API 密钥: 通过查询参数传递您的 API 密钥 ?key=YOUR_API_KEY

将 PDF 转换为 Markdown

将 PDF 文档转换为 Markdown 格式,支持自动图片提取。

请求

POST /api/pdf-to-markdown

参数:

参数类型必需描述
documentobject文档对象
document.typestring固定值 "document_url"
document.document_urlstringPDF 文档 URL 或 base64 数据
filenamestring文件名(建议在使用 base64 数据时提供)
keystringAPI 密钥(查询参数,已登录用户可选)

示例:

使用 PDF URL:

curl -X POST "https://llmocr.com/api/pdf-to-markdown?key=YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "document": {
      "type": "document_url",
      "document_url": "https://llmocr.com/document.pdf"
    }
  }'

使用 Base64 PDF 数据:

curl -X POST "https://llmocr.com/api/pdf-to-markdown?key=YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "document": {
      "type": "document_url",
      "document_url": "data:application/pdf;base64,JVBERi0xLjQK..."
    },
    "filename": "my-document.pdf"
  }'

响应

参数:

参数类型描述
idstring数据库记录 ID
filenamestring文件名
contentstring完整的 Markdown 内容(包含嵌入图片)
formatstring输出格式,固定为 "markdown"
total_pagesnumberPDF 总页数
pages_shownnumber响应中包含的页面数量
is_partialboolean是否因订阅限制而包含部分内容
remaining_pagesnumber由于限制未显示的页面数量(仅在 is_partial 为 true 时出现)
messagestring关于订阅限制的信息消息(仅在 is_partial 为 true 时出现)
timestampnumber处理完成时间戳
payloadstringAPI 端点 URL

示例:

{
  "id": "67890",
  "filename": "document.pdf",
  "content": "# 文档标题\n\n包含图片的文档内容...\n\n![图片](https://storage.llmocr.com/image.jpg)",
  "format": "markdown",
  "total_pages": 29,
  "pages_shown": 21,
  "is_partial": true,
  "remaining_pages": 8,
  "message": "根据您的可用订阅显示 29 页中的 21 页。所有 29 页都已保存,当您有更多订阅页面时,您可以解锁剩余的 8 页。",
  "timestamp": 1758871660489,
  "payload": "https://llmocr.com/api/pdf-to-markdown?key=YOUR_API_KEY"
}
PDF 转 Markdown API - LLMOCR Developer Guide