CaseLeaf

Handbook / The `retype` command

The retype command

A date in the body of a letter is wrong and the correction has to look as though it was always right.

Changes the words under a rectangle, in the page's own font. It is for the correction that has to look as though it was always there, a date, a name, a figure, rather than a box of different-looking text laid over the top. It rewrites the page's own drawing, which is why it needs the rectangle rather than the words.

How you run it

caseleaf retype report.pdf --page 1 --bounds 72;694;420;22 --text "A clause about force majeure, as amended."

What each part means

In full, every part it will take:

caseleaf retype <file> --page <n> --bounds <x;y;w;h> --text <words> [--line] [--to <file>]
part what it is for
<file> The PDF to work on, as a path, such as report.pdf beside you, or the full path to it. This command writes to it unless you send the result somewhere else with --to.
--bounds The rectangle, as four numbers: distance from the left, distance from the bottom, width, height, all in points, 72 to the inch. 72,540,180,24 is a box an inch in from the left, near the top of an A4 sheet. Commas, semicolons or spaces all separate them, and since a semicolon ends a command in most shells, that spelling wants quoting: --bounds "72;540;180;24".
--text What the words should say now, in quotation marks, for example --text "3 March 2026". Empty deletes them instead.
--line Treat the rectangle as a whole line. A typesetter may have split one line into several pieces of drawing, and without this only the piece under the rectangle is replaced.
--to Where to write the result, as a path. The shape above shows which format this command writes. Left out, the document you named is rewritten where it stands, because --to chooses where, not whether. Give one to keep the original.
--page Which sheet, counting from 1, so --page 4 is the fourth sheet as it sits in the file, whatever number is printed on it. This command needs it.

What comes back

Asked of a short sample document, it answers as below. The sample has eight sheets, a highlight and a note left by a reviewer, a web link, a small table, two pictures and one form field already filled in.

{
  "bytes" : 91622,
  "how" : "appended",
  "lineMovedBy" : -98,
  "page" : 1,
  "runs" : 1,
  "text" : "A clause about force majeure, as amended.",
  "to" : "report.pdf",
  "written" : true
}

The same thing from AppleScript

Everything above can be asked for from a script instead. There is one AppleScript command, perform: on names the document, and options takes the rest exactly as you would type it.

tell application "CaseLeaf"
    perform "retype" on "/path/to/report.pdf" ¬
        options "--page 1 --bounds 72;694;420;22 --text \"A clause about force majeure, as amended.\""
end tell

All the commands · Asking from a script · Contents