PDF kit command

text.edit

Edit text

Replace the text of one paragraph (paragraph, from text.listParagraphs: rewrapped to the paragraph's width with its line spacing) or one line (line, from text.listLines) in place, keeping position, size and colour. For a paragraph, also change its formatting: font (helvetica, times, courier) with bold/italic, size (points), color (#rrggbb), align (left, center, right, justify), underline, lineSpacing (× size), charSpacing (points) and scale (horizontal, percent), or move it (dx, dy in points; up is +dy) and rewrap it to a new width (points); text may then be omitted. Its own font is reused when it can show every character and no font/weight change is requested; otherwise it uses a standard font matching the source style or, for Japanese and other text no standard font can show (Cyrillic, Greek), real Mincho/Gothic fallback outlines matching the requested/source family and available weight, from a face that has every character (the result shows the font used). Missing Japanese weights use Regular, not synthetic bold; the small web build has only Gothic Regular. Paragraph bold may be set without font to keep the source family. Text that no available font can show is refused. Undoable.

Kit
PDF 0.1.0 (.pdf)
Changes the document
yes

Parameters

Parameters of text.edit
NameTypeRequiredDescription
align"left" | "center" | "right" | "justify"no
boldbooleanno
charSpacingnumbernoPoints.
colorstringno#rrggbb
dxnumbernoParagraph only: move right by this many points (negative: left).
dynumbernoParagraph only: move up by this many points (negative: down).
font"helvetica" | "times" | "courier"no
italicbooleanno
lineintegerno(minimum 1)
lineSpacingnumbernoMultiple of the font size (1.2 is ordinary).
pageintegeryes(minimum 1)
paragraphintegerno(minimum 1)
scalenumbernoHorizontal scale in percent.
sizenumberno
textstringno
underlinebooleanno
widthnumbernoParagraph only: rewrap to this width in points (dragging the box's edge).

Call through pdf_run

text
pdf_run {
  "path": "<file>.pdf",
  "steps": [{ "command": "text.edit", "params": { "page": <integer> } }]
}

The required parameters, with placeholders for their types: not a tested example. Optional: align, bold, charSpacing, color, dx, dy, font, italic, line, lineSpacing, paragraph, scale, size, text, underline, width. 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": {
    "align": {
      "enum": [
        "left",
        "center",
        "right",
        "justify"
      ],
      "type": "string"
    },
    "bold": {
      "type": "boolean"
    },
    "charSpacing": {
      "description": "Points.",
      "type": "number"
    },
    "color": {
      "description": "#rrggbb",
      "type": "string"
    },
    "dx": {
      "description": "Paragraph only: move right by this many points (negative: left).",
      "type": "number"
    },
    "dy": {
      "description": "Paragraph only: move up by this many points (negative: down).",
      "type": "number"
    },
    "font": {
      "enum": [
        "helvetica",
        "times",
        "courier"
      ],
      "type": "string"
    },
    "italic": {
      "type": "boolean"
    },
    "line": {
      "description": "(minimum 1)",
      "type": "integer"
    },
    "lineSpacing": {
      "description": "Multiple of the font size (1.2 is ordinary).",
      "type": "number"
    },
    "page": {
      "description": "(minimum 1)",
      "type": "integer"
    },
    "paragraph": {
      "description": "(minimum 1)",
      "type": "integer"
    },
    "scale": {
      "description": "Horizontal scale in percent.",
      "type": "number"
    },
    "size": {
      "type": "number"
    },
    "text": {
      "type": "string"
    },
    "underline": {
      "type": "boolean"
    },
    "width": {
      "description": "Paragraph only: rewrap to this width in points (dragging the box's edge).",
      "type": "number"
    }
  },
  "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.