PDF kit command

text.extract

Extract text

Extract the text of some or all pages, in reading order. With rect, only the text inside that rectangle on each page, as Column select takes it: one row per visual line, side-by-side pieces (table cells) separated by a tab.

Kit
PDF 0.1.0 (.pdf)
Changes the document
no

Parameters

Parameters of text.extract
NameTypeRequiredDescription
pagesinteger[]no1-based page numbers to extract (default: all). (minItems 1)
rectnumber[]noColumn select: [x0, y0, x1, y1] in points from the top-left of the displayed page; a glyph counts when its centre is inside. (maxItems 4, minItems 4)

Call through pdf_run

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

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

Result

Result of text.extract
NameTypeRequiredDescription
pagesobject[]no
Result JSON Schema
json
{
  "additionalProperties": true,
  "properties": {
    "pages": {
      "items": {
        "additionalProperties": true,
        "properties": {
          "page": {
            "type": "number"
          },
          "text": {
            "type": "string"
          }
        },
        "type": "object"
      },
      "type": "array"
    }
  },
  "type": "object"
}

Parameter schema

json
{
  "additionalProperties": false,
  "properties": {
    "pages": {
      "description": "1-based page numbers to extract (default: all). (minItems 1)",
      "items": {
        "description": "(minimum 1)",
        "type": "integer"
      },
      "type": "array"
    },
    "rect": {
      "description": "Column select: [x0, y0, x1, y1] in points from the top-left of the displayed page; a glyph counts when its centre is inside. (maxItems 4, minItems 4)",
      "items": {
        "type": "number"
      },
      "type": "array"
    }
  },
  "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.