API 文档
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参数:
| 参数 | 类型 | 必需 | 描述 |
|---|---|---|---|
| document | object | 是 | 文档对象 |
| document.type | string | 是 | 固定值 "document_url" |
| document.document_url | string | 是 | PDF 文档 URL 或 base64 数据 |
| filename | string | 否 | 文件名(建议在使用 base64 数据时提供) |
| key | string | 否 | API 密钥(查询参数,已登录用户可选) |
示例:
使用 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"
}'响应
参数:
| 参数 | 类型 | 描述 |
|---|---|---|
| id | string | 数据库记录 ID |
| filename | string | 文件名 |
| content | string | 完整的 Markdown 内容(包含嵌入图片) |
| format | string | 输出格式,固定为 "markdown" |
| total_pages | number | PDF 总页数 |
| pages_shown | number | 响应中包含的页面数量 |
| is_partial | boolean | 是否因订阅限制而包含部分内容 |
| remaining_pages | number | 由于限制未显示的页面数量(仅在 is_partial 为 true 时出现) |
| message | string | 关于订阅限制的信息消息(仅在 is_partial 为 true 时出现) |
| timestamp | number | 处理完成时间戳 |
| payload | string | API 端点 URL |
示例:
{
"id": "67890",
"filename": "document.pdf",
"content": "# 文档标题\n\n包含图片的文档内容...\n\n",
"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"
}