Saltar al contenido principal

Convertir PDF a Excel

PDF4me Convertir PDF a Excel es un REST punto final que extrae tablas y texto de un PDF y devuelve un objeto editable Excel libro de ejercicios. POST a Base64 PDF a /api/v2/ConvertPdfToExcel, seleccione Draft o Alta calidad, habilite OCR para escaneado pagesy guardar el devuelto .xlsx bytes. Una llamada, sin necesidad de volver a escribir manualmente.

Lo que hace este punto final

Envía uno PDF entra, consigue uno Excel El motor detecta las estructuras de tabla en cada página y las reconstruye como celdas de hoja de cálculo, extrayendo el texto circundante. qualityType cambia entre extracción rápida de capa de texto (Borrador) y reconocimiento por página para escaneos (Alto), y ocrWhenNeeded carreras OCR automáticamente cuando una página no tiene capa de texto. La respuesta es el texto sin procesar. .xlsx binario (200) o un Location encuesta URL (202).

Entradas de blog relacionadas
Aún no hay ninguna entrada de blog sobre esta función; estará disponible próximamente.
Mientras tanto, echa un vistazo al blog de PDF4me para encontrar tutoriales y flujos de trabajo para todas las plataformas.
Visita el blog

Autenticando su API Pedido

Cada PDF4me REST La llamada debe incluir su API clave en el Authorization Encabezado como autenticación básica. Obtenga o cambie su clave desde el panel de desarrollador.

Punto final

POST/api/v2/ConvertirPDFaExcel

Datos importantes que no debes perderte

Draft y High se facturan de forma diferente.
Costes de borrador 1 API Llamada por archivo y lee la capa de texto existente. Costos altos 2 API llamadas por página y reprocesa cada página, que es lo que hace que se escanee PDFs trabajo. No ejecutar en alto en un dispositivo digital limpio PDFs; pagas por página sin obtener nada a cambio.
outputFormat y ocrWhenNeeded son booleanos
Los ejemplos de código oficiales envían verdadero / FALSO JSON booleanos para ambos campos. Las versiones anteriores de esta página mostraban valores de cadena como "Sí"; utilice valores booleanos como en los ejemplos a continuación.
Async devuelve 202 + Location encabezado
Con asíncrono: verdadero el API puede responder 202 con un Location encabezado. GET eso URL (mismo Authorization) hasta que devuelva 200 con el binario del libro de trabajo. Las muestras oficiales realizan sondeos cada 10 segundos, hasta 10 reintentos.

HTTP configuración

Método: POST
URL: https://api.pdf4me.com/api/v2/ConvertPdfToExcel
Tipo de contenido: aplicación/json
Authorization: Básico <tu PDF4me API clave>

Enviar asíncrono: verdadero en el cuerpo. 200 devuelve el convertido .xlsx Libro de trabajo como bytes binarios. 202 devuelve un Location encabezado con una encuesta URL; GET eso URL con el mismo Authorization encabezado hasta que devuelva 200 con el binario del libro de trabajo.

¿Qué modo de calidad debo elegir: Draft o Alto?

Draft lee la capa de texto que ya existe dentro de un documento creado digitalmente. PDF. Alta renderización y reconoce cada página, lo que es más lento y cuesta más, pero es el único modo que funciona con escaneos, fotos de documentos y solo imágenes. pages.

Draft vs HighBorradorAlto
Lo mejor paraCreado digitalmente PDFs con texto seleccionableEscaneado o basado en imágenes PDFs
Costo1 API llamada por archivo2 API llamadas por página
OCRNo se aplicaAplicado por página (par con ocrWhenNeeded: true)
VelocidadRápido, pase únicoReconocimiento más lento, página por página
Cuando las mesas vuelven vacíasReintentar con altoControlar language si el texto está ilegible

API campos corporales

ParámetroRequeridoTipoLo que haceEjemplo
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

Cargas útiles de ejemplo

Modo borrador. digital PDF con texto seleccionable

{
"docContent": "JVBERi0xLjcKJcfsj6IKNSAwIG9iago8PAovVHlwZSAvQ2F0YWxvZw...",
"docName": "invoice-report.pdf",
"qualityType": "Draft",
"mergeAllSheets": true,
"outputFormat": true,
"ocrWhenNeeded": true,
"async": true
}

Modo alto. escaneado PDF con OCR

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

Consejos para el cobro de carteros

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.

Ejemplo de 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

¿Qué significa el API ¿devolver?

Una conversión exitosa devuelve el Excel El libro de trabajo en sí, no un JSON envoltorio. La salida es un moderno Oficina abierta XML libro de trabajo (.xlsx), el valor predeterminado XMLformato basado en compatible con todas las versiones actuales de Excel. Analice los tres casos que se describen a continuación.

CampoTipoLo que contiene
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.

Ejemplos de código

Implementaciones funcionales de extremo a extremo, cada una con un ejemplo. PDF y la carga útil exacta de esta página:

Preguntas frecuentes

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.

Acciones relacionadas

La misma tarea en otras plataformas.

Obtén ayuda