跳到主要内容

转变 PDFExcel

PDF4me 转变 PDFExcel 是一个 REST 从中提取表格和文本的端点 PDF 并返回一个可编辑对象 Excel 工作簿。 POST 一个 Base64 PDF/api/v2/ConvertPdfToExcel选择草稿或高质量,启用 OCR 扫描 pages并保存返回的结果 .xlsx 字节。一次调用,无需手动重新输入。

此端点的作用

发送一个 PDF 进去,得到一个 Excel 工作簿已导出。引擎会检测每页上的表格结构,并将其重建为电子表格单元格,同时提取周围的文本。 qualityType 在快速文本层提取和快速文本层提取之间切换(草稿)以及逐页扫描识别(高的), 和 ocrWhenNeeded 跑步 OCR 当页面没有文本层时,会自动执行此操作。响应是原始数据。 .xlsx 二进制(200)或 Location 民意调查 URL (202)

相关博客文章
目前尚无关于此功能的博客文章——敬请期待。
在此期间,您可以浏览 PDF4me 博客,查看适用于各平台的教程和工作流程。
访问博客

验证您的身份 API 要求

每一个 PDF4me REST 通话必须包含您的 API 关键在于 Authorization 请求头设置为基本身份验证。请从开发者控制面板获取或轮换您的密钥。

端点

POST/api/v2/将Pdf转换为Excel

您不容错过的重要事实

Draft 和 High 的计费方式不同。
草案费用 1 API 每个文件调用一次,读取现有文本层。成本高昂 2 API 每页调用并重新处理每一页,这就是扫描的原因。 PDFs 工作。不要在干净的数字设备上高负荷运行。 PDFs你为每一页付费,却什么都没得到。
outputFormatocrWhenNeeded 是布尔值
官方代码样本已发送 真的 / 错误的 JSON 两个字段均为布尔值。此页面的旧版本显示的是字符串值,例如: “是的”; 使用布尔值,如下示例所示。
Async 返回 202 + Location 标题
异步:是API 可能会以 202 回应 Location 标题。 GETURL (相同的 Authorization直到返回 200 并包含工作簿二进制文件为止。官方示例每 10 秒轮询一次,最多重试 10 次。

HTTP 设置

方法: POST
URL https://api.pdf4me.com/api/v2/ConvertPdfToExcel
内容类型: application/json
Authorization 基本 <您的 PDF4me API 键>

发送 异步:是 在体内。 200 返回转换后的结果 .xlsx 工作簿以二进制字节形式保存。 202 返回一个 Location 带有投票的标题 URLGETURLAuthorization 直到返回 200 并带有工作簿二进制文件为止。

我应该选择哪种画质模式:草稿模式还是高画质模式?

Draft 读取数字创建内容中已存在的文本层。 PDF高分辨率模式会重新渲染并识别每一页,虽然速度较慢且成本更高,但它是唯一适用于扫描件、文档照片和纯图像文件的模式。 pages

选秀对阵高阶草稿高的
最适合数字创作 PDFs 可选择文本扫描或基于图像的 PDFs
成本1 API 每个文件的调用2 API 每页调用次数
OCR未应用按页应用(与 ocrWhenNeeded: true
速度快速、单次通过较慢的逐页识别
当餐桌空着的时候重试高查看 language 如果文本乱码

API 身体场

范围必需的类型它的作用例子
docContentRequiredstringBase64-encoded bytes of the source PDF. Strip any data:application/pdf;base64, prefix before posting.JVBERi0xLjcK...
docNameRequiredstringSource filename including the .pdf extension. Used to derive the output filename.invoice-report.pdf
qualityTypeRequiredstringDraft for text-based PDFs (1 API call per file). High for scanned or image-based PDFs (2 API calls per page).Draft
languageConditionalstringLanguage of the text in the source file. Set only when the converted output is not recognizable; otherwise let the engine detect it.English
mergeAllSheetsOptionalbooleantrue combines all extracted content into a single worksheet. false keeps content on separate worksheets.true
outputFormatOptionalbooleanOutput format flag sent as a JSON boolean in the official samples.true
ocrWhenNeededOptionalbooleanRuns OCR automatically on pages without a text layer. Keep true unless you explicitly want recognition skipped.true
asyncOptionalbooleantrue 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
}

高模式扫描 PDFOCR

{
"docContent": "JVBERi0xLjcKJcfsj6IKNSAwIG9iago8PAovVHlwZSAvQ2F0YWxvZw...",
"docName": "scanned-statement.pdf",
"qualityType": "High",
"mergeAllSheets": false,
"language": "English",
"outputFormat": true,
"ocrWhenNeeded": true,
"async": true
}

邮递员收款小贴士

Headers
Content-Type: application/json + Authorization: Basic <apiKey>.
Body
raw JSON. Copy one of the payloads above and replace docContent with your Base64.
Response
Use Send and Download so Postman saves the binary body as a .xlsx file when status is 200. If 202, GET the Location URL with the same Authorization until 200.
Quality
Start with Draft. Only switch to High when tables come back empty, and expect 2 API calls per page in that mode.

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)BinaryThe 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)BinaryThe finished workbook, returned once processing completes. The official samples poll every 10 seconds, up to 10 retries.
Poll response (HTTP 202)EmptyJob still processing. Wait and poll the same Location URL again.

代码示例

提供完整的端到端实施方案,每个方案都附带示例。 PDF 以及此页面的确切有效载荷:

常问问题

Which quality mode should I choose, Draft or High?+
Draft is for digitally created PDFs with a real text layer and costs 1 API call per file. High is for scanned or image-based PDFs and costs 2 API calls per page. Start with Draft; switch to High only when tables come back empty or garbled.
Can the API extract tables from a scanned PDF?+
Yes. Set qualityType to High and ocrWhenNeeded to true. The engine runs OCR on pages without a text layer and reconstructs detected tables as spreadsheet cells in the output workbook.
What does mergeAllSheets do?+
With mergeAllSheets true the extracted content is combined into a single worksheet. With false, content is kept on separate worksheets, so a multi-page PDF maps to multiple sheets in the workbook.
When do I need the language field?+
Only when the converted output is not recognizable. The engine detects the document language automatically; set language explicitly when recognition returns garbled text for your source language.
Is the response JSON or the file itself?+
The file itself. A 200 response body is the raw .xlsx binary. Do not JSON-parse it; write the bytes to disk. Only the 202 case involves reading a header (Location) instead of the body.
My tables came back as plain text without cell structure. What now?+
Rerun with qualityType High so each page goes through recognition, and keep ocrWhenNeeded true. If the text itself is garbled rather than misplaced, set the language field to match the document.
How large can the PDF be?+
Large and scanned files are exactly what the async pattern is for. Send async true and be prepared to poll the Location URL; the official samples poll every 10 seconds, up to 10 retries, before timing out.
Can I get XLS instead of XLSX?+
No. The endpoint returns a modern Open XML workbook (.xlsx). Legacy .xls output is not offered; every current version of Excel, LibreOffice, and Google Sheets opens .xlsx.

相关行动

在其他平台上执行相同的任务

获取帮助