POST /scan/scan_pdf

One photo in, one PDF out, with a text layer so the file can be searched, selected and archived. Several photos produce one multi-page PDF.

Request contract

POST https://api.scankit.io/scan/scan_pdf takes multipart/form-data. Send file for a single page or files repeated for a multi-page document.

ParameterDefaultWhat it does
file or filesrequiredOne image, or several images for a multi-page PDF.
ocr_langengLanguage of the text layer. Usable values are eng and deu. eng is the default, deu is the only other value with an effect, any other value is treated as eng.
ocr_variantoptionalSet it to lang to run the recognition on the language-aware function, which understands 75 language codes. Without it the default function is used and only eng and deu have an effect.
  • The response is the PDF itself: Content-Type application/pdf, filename scan.pdf, or multipage_scan.pdf for several pages.
  • Straighten first when quality matters: POST /scan/crop output as the input to this endpoint gives the cleanest text layer.

Examples

cURL, single page:

bash
curl -X POST "https://api.scankit.io/scan/scan_pdf" \
  -H "X-API-Key: YOUR_API_KEY" \
  -F "file=@document.jpg" \
  -F "ocr_lang=eng" \
  -o scan.pdf

Python, the same call with error handling:

python
import requests

with open("document.jpg", "rb") as fh:
    response = requests.post(
        "https://api.scankit.io/scan/scan_pdf",
        headers={"X-API-Key": "YOUR_API_KEY"},
        files={"file": ("document.jpg", fh, "image/jpeg")},
        data={"ocr_lang": "eng"},
        timeout=120,
    )

response.raise_for_status()
with open("scan.pdf", "wb") as out:
    out.write(response.content)

Errors

StatusMeaningWhat to do
400No fileSend file for one page or files for several pages.
401Missing API Key or Invalid API KeySend the X-API-Key header with a key from an active account.
402Insufficient creditsTop up credits in the dashboard.
429Rate limitWait for the seconds given in Retry-After, then retry.
500PDF generation failedThe PDF step did not return a document for this input. Retry once, then send the image to support.