メインコンテンツへスキップ

変換する PDF 編集可能 PDF 使用 OCR

PDF4me 変換する PDF 編集可能 PDF 使用 OCR は REST スキャンされたエンドポイント PDFs 検索可能で編集可能。 POST 1 Base64 PDF に /api/v2/ConvertOcrPdf下書きまたは高品質を選択し、 OCR エンジンは実際のテキストレイヤーをドキュメントに書き込みます。レスポンスは完成したテキストを返します。 PDF として Base64 JSON解読して保存する準備ができました。

このエンドポイントの機能

画像ベースまたはスキャンされた PDF そして、認識され選択可能なテキストを含む同じ文書を返します。 qualityType 高速シングルパスと(下書き、1 API ファイルごとの呼び出し)およびページごとの認識(高い、2 API ページあたりの呼び出し回数) ocrWhenNeeded スキップ pages 既に検索可能なもの。出力は Base64 docContent 分野で JSON 応答、または Location 投票 URL 202番で。

関連ブログ記事
この機能に関するブログ記事はまだありません。近日公開予定です。
その間、PDF4me ブログを閲覧して、あらゆるプラットフォームのチュートリアルやワークフローをご覧ください。
ブログをご覧ください →

認証 API リクエスト​

毎 PDF4me REST 電話にはあなたの API キー Authorization ヘッダーを基本認証として設定します。開発者ダッシュボードからキーを取得またはローテーションしてください。

終点​

POST/api/v2/ConvertOcrPdf

見逃してはならない重要な事実​

混合フィールド型:文字列とブール値
ocrWhenNeeded そして outputFormat ストリングスは "真実" / "間違い"、 その間 isAsync そして mergeAllSheets は JSON ブール値。これは公式のコードサンプルに準拠しています。これらを混同すると、400エラーが発生する一般的な原因となります。
回答は JSON生のバイトではなく
200の応答は docName プラス docContent完成した PDF として Base64 文字列。デコード docContent 保存する前に、レスポンス本文をそのままディスクに書き込まないでください。
ドラフトとハイは料金が異なります
ドラフト費用1 API ファイルごとの呼び出し; 高コスト 2 API ページあたりの呼び出し回数であり、スキャン用に構築されたモードです。 ocrWhenNeeded: "真実" すでに検索可能 pages 再処理されるのではなく、スキップされます。

HTTP 設定​

方法: POST
URL: https://api.pdf4me.com/api/v2/ConvertOcrPdf
コンテンツタイプ: アプリケーション/json
Authorization: 基本 <あなたの PDF4me API キー>

送信 isAsync: 真実 体内で。 200 リターン JSON と共に Base64 docContent。 202 を返します Location アンケート付きのヘッダー URL; GET それ URL 同じ Authorization ヘッダーが200を返すまで JSON 結果。

スキャンした画像を作成する方法 PDF 検索可能?​

スキャンされた PDF これは単なる写真です pages何も選択できず、テキスト検索にも何も一致しません。 OCR (光学文字認識については、 概要 OCR 作品)各ページの画像を読み取り、認識された単語を実際のテキスト レイヤーとしてファイルに書き込みます。変換後、ドキュメントはデジタルネイティブのように動作します。 PDF検索、コピー、スクリーンリーダーはすべて機能し、後続のステップに進む準備ができています。 PDF/A アーカイブ または検索と置換。

ドラフト対ハイ下書き高い
最適普通 PDFs 主にテキストレイヤーを持つスキャンされた文書または画像ベースの文書
料金1 API ファイルごとの呼び出し2 API ページあたりの呼び出し回数
認識ライトパス1ページあたりフル表示 OCR
ペアリングocrWhenNeeded: "true" 検索対象をスキップ pageslanguage テキストが文字化けして返ってきた場合

API ボディフィールド​

パラメータ必須その機能例
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"

サンプルペイロード​

高画質モード。スキャンした文書 OCR​

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

下書きモード。混合文書、検索対象をスキップ pages​

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

郵便配達員の集荷に関するヒント​

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の例​

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

何が API 戻る?​

JSON生のファイルバイトではありません。 docContent 完成品を手に入れるためのフィールド PDF。

分野タイプ内容物
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.

コードサンプル​

エンドツーエンドの実装が動作し、それぞれにサンプルがスキャンされています。 PDF そして、このページからの正確なペイロードは次のとおりです。

よくある質問​

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.

関連アクション​

他のプラットフォームでも同じタスクを実行​

ヘルプが必要な場合​