Pular para o conteúdo principal

Converter PDF para Excel

PDF4me Converter PDF para Excel é um REST ponto final que extrai tabelas e texto de um PDF e retorna um editável Excel caderno de exercícios. POST a Base64 PDF para /api/v2/ConvertPdfToExcel, selecione Rascunho ou Alta qualidade, habilite OCR para digitalizado pagese salve o valor retornado. .xlsx bytes. Uma única chamada, sem necessidade de redigitação manual.

O que este endpoint faz

Envia um PDF entra, recebe um Excel planilha gerada. O mecanismo detecta as estruturas de tabela em cada página e as reconstrói como células de planilha, extraindo o texto ao redor. qualityType alterna entre extração rápida da camada de texto (Rascunho) e reconhecimento por página para digitalizações (Alto), e ocrWhenNeeded corridas OCR automaticamente quando uma página não possui camada de texto. A resposta é o texto bruto. .xlsx binário (200) ou um Location enquete URL (202).

Artigos relacionados no blogue
Ainda não há nenhuma publicação no blogue sobre esta funcionalidade — em breve.
Entretanto, explore o blogue da PDF4me para encontrar tutoriais e fluxos de trabalho para todas as plataformas.
Visite o blogue

Autenticando seu API Solicitar

Todo PDF4me REST A chamada deve incluir o seu API chave no Authorization Defina o cabeçalho como autenticação básica. Obtenha ou altere sua chave no painel do desenvolvedor.

Ponto final

POST/api/v2/ConverterPdfParaExcel

Fatos importantes que você não deve perder

Draft e High são cobrados de forma diferente.
Custos do rascunho 1 API Chamada por arquivo e leitura da camada de texto existente. Custos elevados 2 API faz chamadas por página e reprocessa cada página, o que torna o processo mais eficiente. PDFs trabalho. Não execute em alta velocidade em dispositivos digitais limpos. PDFsVocê paga por página sem receber nada em troca.
outputFormat e ocrWhenNeeded são booleanos
Os exemplos de código oficiais enviam verdadeiro / falso JSON Valores booleanos para ambos os campos. Versões antigas desta página exibiam valores de string como "sim"; utilize valores booleanos como nos exemplos abaixo.
Async retorna 202 + Location cabeçalho
Com assíncrono: verdadeiro o API pode responder 202 com um Location cabeçalho. GET que URL (mesmo Authorization) até que retorne 200 com o binário da planilha. Os exemplos oficiais verificam a cada 10 segundos, até um máximo de 10 tentativas.

HTTP configurar

Método: POST
URL: https://api.pdf4me.com/api/v2/ConvertPdfToExcel
Tipo de conteúdo: aplicativo/json
Authorization: Básico <seu PDF4me API chave>

Enviar assíncrono: verdadeiro no corpo. 200 retorna o convertido .xlsx planilha em bytes binários. 202 retorna um Location cabeçalho com uma enquete URL; GET que URL com o mesmo Authorization O cabeçalho deve retornar 200 com o binário da planilha.

Qual modo de qualidade devo escolher: Rascunho ou Alta?

O rascunho lê a camada de texto que já existe dentro de um arquivo criado digitalmente. PDFA opção "Alta qualidade" renderiza e reconhece cada página novamente, o que é mais lento e custoso, mas é o único modo que funciona com digitalizações, fotos de documentos e imagens sem formatação. pages.

Draft vs HighRascunhoAlto
Ideal paraCriado digitalmente PDFs com texto selecionávelDigitalizado ou baseado em imagem PDFs
Custo1 API chamada por arquivo2 API chamadas por página
OCRNão aplicadoAplicado por página (combine com ocrWhenNeeded: true)
VelocidadeRápido, passagem únicaReconhecimento mais lento, página por página.
Quando as mesas voltam a ficar vaziasTente novamente com alta qualidadeVerificar language se o texto estiver ilegível

API campos corporais

ParâmetroObrigatórioTipoO que fazExemplo
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

Exemplos de cargas úteis

Modo rascunho. Digital PDF com texto selecionável

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

Modo alto. Escaneado PDF com OCR

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

Dicas de coleta do carteiro

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.

exemplo 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

O que significa o API retornar?

Uma conversão bem-sucedida retorna o Excel livro de exercícios em si, não um JSON wrapper. A saída é um wrapper moderno. Escritório aberto XML livro de exercícios (.xlsx), o padrão XMLformato baseado em suportado por todas as versões atuais de ExcelAnalise os três casos abaixo.

CampoTipoO que contém
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.

Exemplos de código

Implementações funcionais de ponta a ponta, cada uma com um exemplo. PDF e a carga útil exata desta página:

Perguntas frequentes

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.

Ações relacionadas

A mesma tarefa em outras plataformas.

Obtenha ajuda