Ana içeriğe geç

Dönüştürmek PDF Düzenlenebilir PDF Kullanarak OCR

PDF4me Dönüştürmek PDF Düzenlenebilir PDF kullanarak OCR bir REST taranan uç nokta PDFs Aranabilir ve düzenlenebilir. POST A Base64 PDF ile /api/v2/ConvertOcrPdfTaslak veya Yüksek kalite seçeneklerinden birini seçin ve OCR Motor, belgeye gerçek bir metin katmanı yazar. Yanıt olarak tamamlanmış belge döndürülür. PDF gibi Base64 JSONÇözülmeye ve kaydedilmeye hazır.

Bu uç noktanın işlevi

Görüntü tabanlı veya taranmış bir veri alır. PDF ve tanınan, seçilebilir metni içeren aynı belgeyi geri döndürür. qualityType hızlı tek geçiş arasında geçiş yapar (Taslak1 API dosya başına çağrı) ve sayfa başına tanıma (Yüksek2 API (sayfa başına çağrı sayısı) ocrWhenNeeded atlamalar pages Zaten aranabilir olan. Çıktı şu şekilde gelir: Base64 docContent bir alanda JSON yanıt yoluyla veya bir Location anket URL 202.

İlgili Blog Yazıları
Bu özellik için henüz bir blog yazısı yok — yakında yayınlanacak.
Bu arada, her platforma yönelik eğitimler ve iş akışları için PDF4me bloguna göz atın.
Blogu ziyaret edin

Kimliğinizi Doğrulama API Rica etmek

Her PDF4me REST Çağrınızda mutlaka sizin de bulunmanız gerekiyor. API anahtara girin Authorization Başlıkta Temel kimlik doğrulama (Basic auth) belirtilmiştir. Anahtarınızı geliştirici kontrol panelinden alın veya değiştirin.

Uç nokta

POST/api/v2/ConvertOcrPdf

Kaçırmamanız Gereken Önemli Bilgiler

Karışık alan türleri: metin dizeleri VE mantıksal değerler
ocrWhenNeeded Ve outputFormat TELLER "doğru" / "YANLIŞ", sırasında isAsync Ve mergeAllSheets 'dır' JSON Mantıksal değerler. Bu, resmi kod örneklerini yansıtır; bunları karıştırmak 400 hatasının yaygın bir nedenidir.
Yanıt şudur: JSONham baytlar değil
200 yanıt taşıyor docName artı docContentbitmiş PDF olarak Base64 Dizeyi çöz. docContent Kaydetmeden önce. Yanıt gövdesini olduğu gibi diske yazmayın.
Draft ve High farklı şekilde faturalandırılır.
Taslak maliyeti 1 API Dosya başına çağrı; Yüksek maliyetler 2 API Sayfa başına çağrı sayısı ve taramalar için tasarlanmış moddur. Devam edin. ocrWhenNeeded: "doğru" yani zaten aranabilir pages Yeniden işlenmek yerine atlanırlar.

HTTP kurmak

Yöntem: POST
URL: https://api.pdf4me.com/api/v2/ConvertOcrPdf
İçerik Türü: uygulama/json
Authorization: Temel <sizin PDF4me API anahtar>

Göndermek isAsync: doğru Vücutta. 200 iadeler JSON ile Base64 docContent. 202 bir döndürür Location anket içeren başlık URL; GET O URL aynı şekilde Authorization başlık 200 değerini döndürene kadar JSON sonuç.

Taranmış bir belgeyi nasıl oluşturursunuz? PDF Aranabilir mi?

Taranmış bir PDF sadece resimlerdir pagesHiçbir şey seçilemiyor ve metin aramasıyla eşleşen hiçbir şey yok. OCR (optik karakter tanıma, bakınız) nasıl OCR işlerBu işlem, her sayfa görüntüsünü okur ve tanınan kelimeleri gerçek bir metin katmanı olarak dosyaya yazar. Dönüştürme işleminden sonra belge, dijital olarak oluşturulmuş bir belge gibi davranır. PDFArama, kopyalama ve ekran okuyucular sorunsuz çalışıyor ve sonraki adımlar için hazır durumda. PDF/A arşivleme veya bul ve değiştir.

Taslak vs YüksekTaslakYüksek
En iyisiNormal PDFs çoğunlukla metin katmanına sahip olanlarTaranmış veya görüntü tabanlı belgeler
Maliyet1 API dosya başına çağrı2 API sayfa başına çağrılar
TanımaHafif geçişSayfa başına tam OCR
Şununla eşleştirinocrWhenNeeded: "true" aranabilir olanı atla pageslanguage metin bozuk bir şekilde geri döndüğünde

API vücut alanları

ParametreGerekliTipNe işe yarar?Örnek
docContentRequiredstringBase64-encoded bytes of the source PDF. Strip any data:application/pdf;base64, prefix before posting.JVBERi0xLjcK...
docNameRequiredstringSource filename including the .pdf extension. Used for the output docName.scanned-contract.pdf
qualityTypeRequiredstringDraft for normal PDFs (1 API call per file). High for scanned documents (2 API calls per page).High
ocrWhenNeededRequiredstringThe string "true" skips pages that already have a searchable text layer; "false" forces OCR on every page."true"
outputFormatRequiredstringOutput format flag, sent as the string "true" in the official samples."true"
languageConditionalstringLanguage of the source text (English, Spanish, French, German, and others). Set only when the recognized output is garbled; otherwise let the engine detect it.English
mergeAllSheetsOptionalbooleanJSON boolean carried by the official samples; relevant to sheet-based sources.true
isAsyncOptionalbooleantrue enables the 202 + Location polling pattern, recommended for large scans.true

Örnek yükler

Yüksek mod. Taranmış belge ile OCR

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

Taslak modu. Karma belge, aranabilir özelliği atla. pages

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

Postacı tahsilat ipuçları

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.

curl örneği

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']))"

Ne anlama geliyor? API geri dönmek?

JSONHam dosya baytları değil. Kodunu çözün. docContent bitmiş ürünü almak için alan PDF.

AlanTipİçeriğinde neler var?
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.

Kod örnekleri

Uçtan uca uygulamalar üzerinde çalışılıyor, her birinde taranmış bir örnek bulunuyor. PDF ve bu sayfadaki tam içerik:

SSS

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.

İlgili işlemler

Diğer platformlarda aynı görev

Yardım Alın