转变 PDF 到 Excel
PDF4me 转变 PDF 到 Excel 是一个 REST 从中提取表格和文本的端点 PDF 并返回一个可编辑对象 Excel 工作簿。 POST 一个 Base64 PDF 到 /api/v2/ConvertPdfToExcel选择草稿或高质量,启用 OCR 扫描 pages并保存返回的结果 .xlsx 字节。一次调用,无需手动重新输入。
发送一个 PDF 进去,得到一个 Excel 工作簿已导出。引擎会检测每页上的表格结构,并将其重建为电子表格单元格,同时提取周围的文本。 qualityType 在快速文本层提取和快速文本层提取之间切换(草稿)以及逐页扫描识别(高的), 和 ocrWhenNeeded 跑步 OCR 当页面没有文本层时,会自动执行此操作。响应是原始数据。 .xlsx 二进制(200)或 Location 民意调查 URL (202)
验证您的身份 API 要求
每一个 PDF4me REST 通话必须包含您的 API 关键在于 Authorization 请求头设置为基本身份验证。请从开发者控制面板获取或轮换您的密钥。
端点
/api/v2/将Pdf转换为Excel您不容错过的重要事实
outputFormat 和 ocrWhenNeeded 是布尔值真的 / 错误的 JSON 两个字段均为布尔值。此页面的旧版本显示的是字符串值,例如: “是的”; 使用布尔值,如下示例所示。异步:是 这 API 可能会以 202 回应 Location 标题。 GET 那 URL (相同的 Authorization直到返回 200 并包含工作簿二进制文件为止。官方示例每 10 秒轮询一次,最多重试 10 次。HTTP 设置
方法: POST
URL: https://api.pdf4me.com/api/v2/ConvertPdfToExcel
内容类型: application/json
Authorization: 基本 <您的 PDF4me API 键>
发送 异步:是 在体内。 200 返回转换后的结果 .xlsx 工作簿以二进制字节形式保存。 202 返回一个 Location 带有投票的标题 URL; GET 那 URL 与 Authorization 直到返回 200 并带有工作簿二进制文件为止。
我应该选择哪种画质模式:草稿模式还是高画质模式?
Draft 读取数字创建内容中已存在的文本层。 PDF高分辨率模式会重新渲染并识别每一页,虽然速度较慢且成本更高,但它是唯一适用于扫描件、文档照片和纯图像文件的模式。 pages。
| 选秀对阵高阶 | 草稿 | 高的 |
|---|---|---|
| 最适合 | 数字创作 PDFs 可选择文本 | 扫描或基于图像的 PDFs |
| 成本 | 1 API 每个文件的调用 | 2 API 每页调用次数 |
| OCR | 未应用 | 按页应用(与 ocrWhenNeeded: true) |
| 速度 | 快速、单次通过 | 较慢的逐页识别 |
| 当餐桌空着的时候 | 重试高 | 查看 language 如果文本乱码 |
API 身体场
| 范围 | 必需的 | 类型 | 它的作用 | 例子 |
|---|---|---|---|---|
docContent | Required | string | Base64-encoded bytes of the source PDF. Strip any data:application/pdf;base64, prefix before posting. | JVBERi0xLjcK... |
docName | Required | string | Source filename including the .pdf extension. Used to derive the output filename. | invoice-report.pdf |
qualityType | Required | string | Draft for text-based PDFs (1 API call per file). High for scanned or image-based PDFs (2 API calls per page). | Draft |
language | Conditional | string | Language of the text in the source file. Set only when the converted output is not recognizable; otherwise let the engine detect it. | English |
mergeAllSheets | Optional | boolean | true combines all extracted content into a single worksheet. false keeps content on separate worksheets. | true |
outputFormat | Optional | boolean | Output format flag sent as a JSON boolean in the official samples. | true |
ocrWhenNeeded | Optional | boolean | Runs OCR automatically on pages without a text layer. Keep true unless you explicitly want recognition skipped. | true |
async | Optional | boolean | true enables the 202 + Location polling pattern, recommended for large or scanned files. | true |
示例有效载荷
草稿模式。数字版 PDF 可选择文本
{
"docContent": "JVBERi0xLjcKJcfsj6IKNSAwIG9iago8PAovVHlwZSAvQ2F0YWxvZw...",
"docName": "invoice-report.pdf",
"qualityType": "Draft",
"mergeAllSheets": true,
"outputFormat": true,
"ocrWhenNeeded": true,
"async": true
}
高模式扫描 PDF 和 OCR
{
"docContent": "JVBERi0xLjcKJcfsj6IKNSAwIG9iago8PAovVHlwZSAvQ2F0YWxvZw...",
"docName": "scanned-statement.pdf",
"qualityType": "High",
"mergeAllSheets": false,
"language": "English",
"outputFormat": true,
"ocrWhenNeeded": true,
"async": true
}
邮递员收款小贴士
curl 示例
curl -X POST https://api.pdf4me.com/api/v2/ConvertPdfToExcel \
-H "Content-Type: application/json" \
-H "Authorization: Basic YOUR_API_KEY" \
-d '{
"docContent": "'"$(base64 -w 0 invoice-report.pdf)"'",
"docName": "invoice-report.pdf",
"qualityType": "Draft",
"mergeAllSheets": true,
"outputFormat": true,
"ocrWhenNeeded": true,
"async": true
}' \
--output converted.xlsx
什么 API 返回?
转换成功后,返回 Excel 工作簿本身,而不是 JSON 包装器。输出是一个现代的 办公室开放 XML 工作簿(.xlsx),默认值 XML基于格式 当前所有版本均支持 Excel处理以下三种情况。
| 场地 | 类型 | 它包含什么 |
|---|---|---|
| Response body (HTTP 200) | Binary | The converted .xlsx workbook bytes. Write them straight to a file with an .xlsx extension. |
| Location header (HTTP 202) | String (URL) | Poll URL for an async job that is still running. GET it with the same Authorization header. |
| Poll response (HTTP 200) | Binary | The finished workbook, returned once processing completes. The official samples poll every 10 seconds, up to 10 retries. |
| Poll response (HTTP 202) | Empty | Job still processing. Wait and poll the same Location URL again. |
代码示例
提供完整的端到端实施方案,每个方案都附带示例。 PDF 以及此页面的确切有效载荷: