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"
}