---
title: "text.edit: Edit text — PDF kit command — Kition"
description: "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."
canonical: "https://developer.kition.ai/docs/kits/pdf/commands/text.edit"
---

> Canonical HTML: [https://developer.kition.ai/docs/kits/pdf/commands/text.edit](https://developer.kition.ai/docs/kits/pdf/commands/text.edit)

# 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); reference: [PDF kit commands](https://developer.kition.ai/docs/kits/pdf.md)
- Changes the document: yes

## Parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `align` | `"left" \| "center" \| "right" \| "justify"` | no |  |
| `bold` | `boolean` | no |  |
| `charSpacing` | `number` | no | Points. |
| `color` | `string` | no | #rrggbb |
| `dx` | `number` | no | Paragraph only: move right by this many points (negative: left). |
| `dy` | `number` | no | Paragraph only: move up by this many points (negative: down). |
| `font` | `"helvetica" \| "times" \| "courier"` | no |  |
| `italic` | `boolean` | no |  |
| `line` | `integer` | no | (minimum 1) |
| `lineSpacing` | `number` | no | Multiple of the font size (1.2 is ordinary). |
| `page` | `integer` | yes | (minimum 1) |
| `paragraph` | `integer` | no | (minimum 1) |
| `scale` | `number` | no | Horizontal scale in percent. |
| `size` | `number` | no |  |
| `text` | `string` | no |  |
| `underline` | `boolean` | no |  |
| `width` | `number` | no | Paragraph 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/pdf-darwin-arm64@0.1.0 and the kit itself (pdf_commands through @kition/cli@0.1.1, built from KitionAI/kition-pdf@b0d2725).
