Passa al contenuto principale

Convertire PDF Modificabile PDF Utilizzando OCR

PDF4me Convertire PDF Modificabile PDF utilizzando OCR è un REST punto finale che viene scansionato PDFs ricercabile e modificabile. POST UN Base64 PDF A /api/v2/ConvertOcrPdf, scegli Bozza o Alta qualità e il OCR Il motore scrive un livello di testo reale nel documento. La risposta restituisce il risultato finale PDF COME Base64 JSON, pronto per essere decodificato e salvato.

Cosa fa questo endpoint

Esegue un'immagine basata su una scansione PDF e restituisce lo stesso documento con il testo riconosciuto e selezionabile. qualityType passa tra un singolo passaggio veloce (Bozza, 1 API chiamata per file) e riconoscimento per pagina (Alto, 2 API chiamate per pagina), mentre ocrWhenNeeded salti pages che sono già ricercabili. L'output arriva come un Base64 docContent campo in un JSON risposta, o tramite una Location sondaggio URL il 202.

Articoli correlati del blog
Non ci sono ancora post sul blog dedicati a questa funzionalità — in arrivo a breve.
Nel frattempo, dai un'occhiata al blog di PDF4me per trovare tutorial e procedure operative su tutte le piattaforme.
Visita il blog →

Autenticazione del tuo API Richiesta​

Ogni PDF4me REST la chiamata deve includere il tuo API chiave nel Authorization Intestazione come autenticazione di base. Ottieni o ruota la tua chiave dalla dashboard dello sviluppatore.

Punto finale​

POST/api/v2/ConvertOcrPdf

Informazioni importanti da non perdere​

Tipi di campo misti: stringhe E valori booleani
ocrWhenNeeded E outputFormat sono le CORDE "VERO" / "falso", Mentre isAsync E mergeAllSheets Sono JSON valori booleani. Questo rispecchia gli esempi di codice ufficiali; confonderli è una causa comune di errori 400.
La risposta è JSONnon byte grezzi
Una risposta 200 porta docName più docContent, il finito PDF come Base64 stringa. Decodifica docContent Prima di salvare, non scrivere il corpo della risposta su disco così com'è.
Draft e High sono fatturati in modo diverso
Costo della bozza 1 API chiamata per file; costi elevati 2 API chiamate per pagina ed è la modalità creata per le scansioni. Mantieni ocrWhenNeeded: "VERO" così già ricercabile pages vengono saltati invece di essere rielaborati.

HTTP impostare​

Metodo: POST
URL: https://api.pdf4me.com/api/v2/ConvertOcrPdf
Tipo di contenuto: applicazione/json
Authorization: Base <il tuo PDF4me API chiave>

Inviare isAsync: VERO nel corpo. 200 resi JSON con il Base64 docContent. 202 restituisce un Location intestazione con un sondaggio URL; GET Quello URL con lo stesso Authorization intestazione fino a quando non restituisce 200 con l' JSON risultato.

Come si fa una scansione? PDF ricercabile?​

Uno scansionato PDF sono solo immagini di pagesNon è possibile selezionare nulla e non viene trovato alcun risultato nella ricerca testuale. OCR (riconoscimento ottico dei caratteri, vedere il panoramica di come OCR opere) legge l'immagine di ogni pagina e scrive le parole riconosciute nel file come un vero e proprio livello di testo. Dopo la conversione, il documento si comporta come un documento nativo digitale PDF: la ricerca, la copia e i lettori di schermo funzionano tutti ed è pronto per i passaggi successivi come PDF/A archiviazione oppure trova e sostituisci.

Draft vs AltoBozzaAlto
Ideale perNormal PDFs che per lo più hanno un livello di testoDocumenti scansionati o basati su immagini
Costo1 API chiamata per file2 API chiamate per pagina
RiconoscimentoPasso leggeroTutto per pagina OCR
Abbinare conocrWhenNeeded: "true" per saltare la ricerca pageslanguage quando il testo torna indietro incomprensibile

API campi corporei​

ParametroNecessarioCosa faEsempio
jobIdExtOptionalYour own reference for this call. It is stored with the API call log so you can correlate calls with your jobs. Type: string.
integrationsOptionalIntegration identifiers, forwarded unchanged with the job's notification settings. Type: array.
isAsyncOptionalSet to `true` to process the action asynchronously and get a job to poll at `/api/v2/GetActionStatus`. Only honoured by actions that support asynchronous processing. Type: boolean.true
docNameOptionalSource file name including its extension. Several actions dispatch on the extension, so it should always be set; when omitted a per-action default is used. Type: string.scanned-contract.pdf
docContentRequiredThe source file. Accepts the base64-encoded file content, a `pdf4meblobid://<id>` reference to a previously uploaded blob, or an `https` URL to the source document. Required: an empty value fails with `File is empty`. Type: string.JVBERi0xLjcK...
docContentBytesOptionalAlternative raw byte payload for the source file. Type: string.
callBackUrlOptionalOptional URL notified when an asynchronous job completes. Type: string.
qualityTypeOptionalConversion quality. An unrecognised value is rejected with 400. Type: string.High
ocrWhenNeededOptionalParsed as a boolean: pass `true` to run OCR when the source PDF has no text layer. Used by ConvertOcrPdf. Type: string."true"
mergeAllSheetsOptionalConvertPdfToExcel: put every page into a single worksheet. Type: boolean.true
languageOptionalOCR language, for example `English`. Type: string.English
outputFormatOptionalUsed by ConvertPdfToExcel: set to `csv` to receive CSV instead of a workbook, and by ConvertVisio to pick the target format. Type: string."true"

Esempi di carichi utili​

Modalità alta. Documento scansionato con OCR​

{
"docContent": "JVBERi0xLjcKJcfsj6IKNSAwIG9iago8PAovVHlwZSAvQ2F0YWxvZw...",
"docName": "scanned-contract.pdf",
"qualityType": "High",
"ocrWhenNeeded": "true",
"language": "English",
"outputFormat": "true",
"isAsync": true
}

Modalità bozza. Documento misto, salta ricercabile pages​

{
"docContent": "JVBERi0xLjcKJcfsj6IKNSAwIG9iago8PAovVHlwZSAvQ2F0YWxvZw...",
"docName": "mixed-report.pdf",
"qualityType": "Draft",
"ocrWhenNeeded": "true",
"outputFormat": "true",
"isAsync": true
}

Consigli per la raccolta del postino​

Headers
Content-Type: application/json + Authorization: Basic <apiKey>.
Body
raw JSON. Copy a payload above and replace docContent with your Base64. Keep the quotes around "true" for ocrWhenNeeded and outputFormat.
Response
The 200 body is JSON. Copy the docContent value and Base64-decode it to get the PDF. If 202, GET the Location URL with the same Authorization until 200.
Quality
Use High for scans and expect 2 API calls per page. Draft is enough when most pages already have selectable text.

esempio di riccio​

curl -X POST https://api.pdf4me.com/api/v2/ConvertOcrPdf \
-H "Content-Type: application/json" \
-H "Authorization: Basic YOUR_API_KEY" \
-d '{
"docContent": "'"$(base64 -w 0 scanned-contract.pdf)"'",
"docName": "scanned-contract.pdf",
"qualityType": "High",
"ocrWhenNeeded": "true",
"outputFormat": "true",
"isAsync": true
}' | python -c "import sys, json, base64; open('searchable.pdf','wb').write(base64.b64decode(json.load(sys.stdin)['docContent']))"

Che cosa significa il API ritorno?​

JSON, non byte di file grezzi. Decodifica il docContent campo per ottenere il finito PDF.

CampoTipoCosa contiene
docName (HTTP 200)StringThe output PDF filename, derived from the docName you sent.
docContent (HTTP 200)String (Base64)The searchable, editable PDF encoded as Base64. Decode to bytes and save with a .pdf extension.
Location header (HTTP 202)String (URL)Poll URL for an async job that is still running. GET it with the same Authorization header; the official samples poll every 10 seconds, up to 20 retries.
Poll response (HTTP 200)JSONThe same docName + docContent JSON, returned once processing completes.

Esempi di codice​

Implementazioni complete funzionanti, ciascuna con un esempio scansionato PDF e il contenuto esatto di questa pagina:

FAQ​

How do you make a scanned PDF searchable?+
Run it through OCR. POST the Base64 PDF to /api/v2/ConvertOcrPdf with qualityType High and ocrWhenNeeded "true"; the engine recognizes the text on each scanned page and writes a searchable, selectable text layer into the returned PDF.
Is the response the PDF file itself?+
No. ConvertOcrPdf returns JSON: a docName field and a docContent field holding the output PDF as a Base64 string. Decode docContent to bytes before saving the file.
What does ocrWhenNeeded do?+
Set to the string "true", it skips recognition on pages that already have a searchable text layer, saving processing on mixed documents. Set to "false", every page is OCR-processed regardless.
Which quality mode should I use, Draft or High?+
Draft costs 1 API call per file and suits normal PDFs. High costs 2 API calls per page and is built for scanned documents where every page needs recognition. Use High whenever the source is a scan or photo.
Why are some fields strings and others booleans?+
That is the contract the official code samples ship: ocrWhenNeeded and outputFormat are the strings "true" or "false", while isAsync and mergeAllSheets are JSON booleans. Sending the wrong type is a common cause of 400 errors.
The recognized text is garbled. What now?+
Set the language field to match the document (English, Spanish, French, German, and others) and rerun. Language only needs to be set when automatic detection gets it wrong.
Does OCR change how the pages look?+
No. The text layer is added behind the page image, so the visual appearance stays identical while search, selection, and copy start working.
Can I OCR a PDF and then extract its tables to Excel?+
Yes, but you do not need two calls: the Convert PDF to Excel endpoint runs OCR itself when you set its qualityType to High. Use ConvertOcrPdf when the deliverable should stay a PDF.

Azioni correlate​

Stessa attività su altre piattaforme​

Richiedi assistenza​