PDF kit command
text.select
Select text
Read text and highlight rectangles between inclusive nearest-glyph endpoints in displayed page-local top-left points (rotation and crop already applied). Range selection normalizes direction and page order; intermediate pages are complete. Column selection includes glyph centers inside the rectangle and requires one page. Returns {text,pages:[{page,text,rects}]}, retaining blank pages and joining page text with a newline. Refuses spans over 64 pages, text over 1 MiB UTF-8 including page separators, or over 16384 rectangles; never returns a partial selection. A range end is a point (anchor, focus) or a glyph index (anchorGlyph, focusGlyph, as a previous answer's ends gave it); unit widens both ends to whole words, lines or the page (double, triple and quadruple clicks); step moves the focus end by stepBy glyphs, words or lines on its page (Shift with the arrow keys). With ends, a range answer also gives its ends: {anchor:{page,glyph},head:{page,glyph}}, null on a page without text.
- Kit
- PDF 0.1.0 (.pdf)
- Changes the document
- no
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
anchor | number[] | no | Anchor point; or give anchorGlyph. (maxItems 2, minItems 2) |
anchorGlyph | integer | no | The anchor's glyph index on page, in place of anchor (range only). (minimum 0) |
endPage | integer | no | Focus page; defaults to page. (minimum 1) |
ends | boolean | no | Also answer where the range's ends are, as glyphs (range only). |
focus | number[] | no | Focus point; or give focusGlyph. (maxItems 2, minItems 2) |
focusGlyph | integer | no | The focus's glyph index on endPage, in place of focus (range only). (minimum 0) |
mode | "range" | "column" | no | |
page | integer | yes | (minimum 1) |
step | integer | no | Move the focus end this many stepBy units on its page, back when negative (range only). |
stepBy | "glyph" | "word" | "line" | no | |
unit | "glyph" | "word" | "line" | "page" | no | Widen both ends to whole units (range only). |
Call through pdf_run
pdf_run {
"path": "<file>.pdf",
"steps": [{ "command": "text.select", "params": { "page": <integer> } }]
}The required parameters, with placeholders for their types: not a tested example. Optional: anchor, anchorGlyph, endPage, ends, focus, focusGlyph, mode, step, stepBy, unit. pdf_run answers the step’s result in completed[i].result.
Result
| Name | Type | Required | Description |
|---|---|---|---|
pages | object[] | no | |
text | string | no |
Result JSON Schema
{
"additionalProperties": true,
"properties": {
"pages": {
"items": {
"additionalProperties": true,
"properties": {
"page": {
"type": "number"
},
"rects": {
"type": "array"
},
"text": {
"type": "string"
}
},
"type": "object"
},
"type": "array"
},
"text": {
"type": "string"
}
},
"type": "object"
}Parameter schema
{
"additionalProperties": false,
"properties": {
"anchor": {
"description": "Anchor point; or give anchorGlyph. (maxItems 2, minItems 2)",
"items": {
"type": "number"
},
"type": "array"
},
"anchorGlyph": {
"description": "The anchor's glyph index on page, in place of anchor (range only). (minimum 0)",
"type": "integer"
},
"endPage": {
"description": "Focus page; defaults to page. (minimum 1)",
"type": "integer"
},
"ends": {
"default": false,
"description": "Also answer where the range's ends are, as glyphs (range only).",
"type": "boolean"
},
"focus": {
"description": "Focus point; or give focusGlyph. (maxItems 2, minItems 2)",
"items": {
"type": "number"
},
"type": "array"
},
"focusGlyph": {
"description": "The focus's glyph index on endPage, in place of focus (range only). (minimum 0)",
"type": "integer"
},
"mode": {
"default": "range",
"enum": [
"range",
"column"
],
"type": "string"
},
"page": {
"description": "(minimum 1)",
"type": "integer"
},
"step": {
"default": 0,
"description": "Move the focus end this many stepBy units on its page, back when negative (range only).",
"type": "integer"
},
"stepBy": {
"default": "glyph",
"enum": [
"glyph",
"word",
"line"
],
"type": "string"
},
"unit": {
"default": "glyph",
"description": "Widen both ends to whole units (range only).",
"enum": [
"glyph",
"word",
"line",
"page"
],
"type": "string"
}
},
"required": [
"page"
],
"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.