PDF to Searchable PDF API
Create a searchable/editable PDF by adding OCR text to the source PDF.
Feature
Request Mode
| Item | Value |
|---|---|
| Authentication | x-api-key: your_api_key_here |
| Request URL | POST http://localhost:8080/api/v1/process/pdf/pdf |
| Content type | multipart/form-data |
| Success response | PDF file stream |
Request Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
file | File | Source file. Recommended extension: .pdf. | Yes |
options | String | JSON string containing the feature options below. | No |
password | String | Source file open password, used for password-protected PDFs. | No |
Options Parameters
Put the following fields in the options JSON string.
| Parameter | Type | Purpose |
|---|---|---|
isContainImg | Integer or String | Whether to include images in the output. 0 = no, 1 = yes. |
formulaToImage | Integer or String | Whether to render formulas as images. 0 keeps formulas as editable content where possible; 1 renders formulas as images. |
enableOcr | Integer or String | Whether to use OCR. 0 = disabled, 1 = enabled. |
ocrRecognitionLang | String | OCR language code. Supported values: AUTO, CHINESE, CHINESE_TRAD, ENGLISH, KOREAN, JAPANESE, LATIN, DEVANAGARI, CYRILLIC, ARABIC, TAMIL, TELUGU, KANNADA, THAI, GREEK, ESLAV. Default: AUTO. |
ocrOption | String | INVALID_CHARACTER, SCAN_PAGE, INVALID_CHARACTERAND_SCAN_PAGE, or ALL. Default: ALL. |
transparentText | Integer or String | Searchable/editable PDF option. Whether OCR text is transparent over the original page image. |
pageRanges | String | Page ranges to process, starting from page 1. Examples: 1, 1-3, 1,3-5. Empty means all pages. |
isOutputDocumentPerPage | Integer or String | Whether to output each page as a separate document. 0 = no, 1 = yes. |
containPageBackgroundImage | Integer or String | Whether to include page background images. Mainly used with OCR-enabled conversion. |
outputFileName | String | Optional output filename. When present, it is used as the preferred download filename. |
Request Example
bash
curl -X POST "http://localhost:8080/api/v1/process/pdf/pdf" \
-H "x-api-key: your_api_key_here" \
-F "[email protected]" \
-F 'options={"isContainImg":1,"formulaToImage":0,"enableOcr":0,"ocrRecognitionLang":"AUTO","ocrOption":"ALL","transparentText":1,"pageRanges":"","isOutputDocumentPerPage":0}'Response
On success, the API returns the converted file stream with Content-Type and Content-Disposition headers. On failure, the ComPDF Self-hosted returns a normalized error JSON response.