PDF kit command

text.find

Find text

Find a phrase (whitespace-normalised; case-insensitive unless caseSensitive) and return each match with its page and line rectangles in points (origin top-left). With wholeWords, a match may not touch a letter or digit on either side.

Kit
PDF 0.1.0 (.pdf)
Changes the document
no

Parameters

Parameters of text.find
NameTypeRequiredDescription
caseSensitivebooleannoMatch upper and lower case as written.
contextintegernoWith each match, up to this many characters of the page's text before it (before) and after it (after), for a list of results. (maximum 80, minimum 0)
limitintegernoMaximum matches (default 500). (minimum 1)
querystringyes(minLength 1)
wholeWordsbooleannoOnly matches with no letter or digit right before or after them (in Chinese, Japanese and Thai, which have no spaces between words, any character boundary counts).

Call through pdf_run

text
pdf_run {
  "path": "<file>.pdf",
  "steps": [{ "command": "text.find", "params": { "query": <string> } }]
}

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

Result

Result of text.find
NameTypeRequiredDescription
countnumberno
matchesany[]no
querystringno
Result JSON Schema
json
{
  "additionalProperties": true,
  "properties": {
    "count": {
      "type": "number"
    },
    "matches": {
      "type": "array"
    },
    "query": {
      "type": "string"
    }
  },
  "type": "object"
}

Parameter schema

json
{
  "additionalProperties": false,
  "properties": {
    "caseSensitive": {
      "default": false,
      "description": "Match upper and lower case as written.",
      "type": "boolean"
    },
    "context": {
      "description": "With each match, up to this many characters of the page's text before it (before) and after it (after), for a list of results. (maximum 80, minimum 0)",
      "type": "integer"
    },
    "limit": {
      "description": "Maximum matches (default 500). (minimum 1)",
      "type": "integer"
    },
    "query": {
      "description": "(minLength 1)",
      "type": "string"
    },
    "wholeWords": {
      "default": false,
      "description": "Only matches with no letter or digit right before or after them (in Chinese, Japanese and Thai, which have no spaces between words, any character boundary counts).",
      "type": "boolean"
    }
  },
  "required": [
    "query"
  ],
  "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.