PDF kit command

ocr.recognize

Recognize text (OCR)

Scan & OCR ▸ Recognize text: render pages, read the words in them and add them as invisible text over the page image, so scanned pages become searchable and selectable (a searchable image; the image is not changed). Pages that already have text are skipped unless skipTextPages is false. Returns each page's recognised text, word count or why it was skipped. Needs the OCR models (ocr.status). Undoable as one step.

Kit
PDF 0.1.0 (.pdf)
Changes the document
yes

Parameters

Parameters of ocr.recognize
NameTypeRequiredDescription
dpinumbernoResolution pages are read at (default 300; a scanned page is read at most at its own resolution). (maximum 600, minimum 72)
language"en"noDocument language (default en).
pagesinteger[]no1-based page numbers to recognise (default: all). (minItems 1)
skipTextPagesbooleannoLeave pages that already contain text alone (default true).

Call through pdf_run

text
pdf_run {
  "path": "<file>.pdf",
  "steps": [{ "command": "ocr.recognize" }]
}

The required parameters, with placeholders for their types: not a tested example. Optional: dpi, language, pages, skipTextPages. pdf_run answers the step’s result in completed[i].result.

Result

The kit gives no result schema for this command.

Parameter schema

json
{
  "additionalProperties": false,
  "properties": {
    "dpi": {
      "description": "Resolution pages are read at (default 300; a scanned page is read at most at its own resolution). (maximum 600, minimum 72)",
      "type": "number"
    },
    "language": {
      "description": "Document language (default en).",
      "enum": [
        "en"
      ],
      "type": "string"
    },
    "pages": {
      "description": "1-based page numbers to recognise (default: all). (minItems 1)",
      "items": {
        "description": "(minimum 1)",
        "type": "integer"
      },
      "type": "array"
    },
    "skipTextPages": {
      "description": "Leave pages that already contain text alone (default true).",
      "type": "boolean"
    }
  },
  "type": "object"
}

Generated from the command list of @kition/[email protected] and the kit itself (pdf_commands through @kition/[email protected], built from KitionAI/kition-pdf@b0d2725). As data: commands.jsonl.