CaseLeaf

Handbook / The `crop` command

The crop command

One figure from a page has to go into a slide pack, and it has to stay text rather than becoming a screenshot.

Writes a copy cropped to a rectangle. It is for taking one thing off a sheet that carries several: a figure, a table, a clause, when what you want is a document rather than a picture. The original is untouched; extract is the one to use when the region is not a rectangle.

How you run it

caseleaf crop report.pdf --to reviewed.pdf --bounds 72,540,180,24

caseleaf crop report.pdf --to reviewed.pdf --bounds 72,540,180,24 --pages 1,2,3

What each part means

In full, every part it will take:

caseleaf crop <file> --to <output> --bounds x,y,w,h [--pages 1,2,3]
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. It is read and not written.
--to Where to write the result, as a path. The shape above shows which format this command writes. This command needs it, and writes only there: the document you named is left exactly as it was.
--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".
--pages Which sheets, as numbers or ranges separated by commas, so 1,3,5-7 is five sheets. Every command reads that spelling the same way, and a number the document does not have is refused rather than skipped.

Keep only what the rectangle contains: everything outside it is removed from the page's drawing commands, not merely hidden by a crop box.

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.

{
  "pages" : 8,
  "to" : "reviewed.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 "crop" on "/path/to/report.pdf" ¬
        options "--to reviewed.pdf --bounds 72,540,180,24"
end tell

tell application "CaseLeaf"
    perform "crop" on "/path/to/report.pdf" ¬
        options "--to reviewed.pdf --bounds 72,540,180,24 --pages 1,2,3"
end tell

All the commands · Asking from a script · Contents