CaseLeaf

Handbook / The `extract` command

The extract command

A single schedule, drawn round rather than rectangular, has to go to a different reader on its own.

Lifts a region out into its own document. Give a rectangle, or draw a shape around what you want. Use it for the figure that must be sent on its own, or the one clause that is going to a different reader. What comes out is a document, not an image, so the text in it is still text.

How you run it

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

caseleaf extract report.pdf --to reviewed.pdf --bounds 72,540,180,24 --page 1

caseleaf extract report.pdf --to reviewed.pdf --shape 72,540,300,540,72,300

caseleaf extract report.pdf --to reviewed.pdf --shape 72,540,300,540,72,300 --page 1

What each part means

In full, every part it will take:

caseleaf extract <file> --to <output> --bounds x,y,w,h [--page <n>]
caseleaf extract <file> --to <output> --shape x,y x,y x,y [--page <n>]
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".
--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. Left out, the first sheet.
--shape The corners of a closed shape, three or more points as x,y pairs. A comma, a semicolon or a space separates them, in any mixture, so 72,540;300,540;300,400 reads the same as 72,540 300,540 300,400. The ring closes itself, so the first point is not repeated. Use this instead of --bounds when what you want is not a rectangle.

--bounds lifts a rectangle. The application's Copy Crop Rectangle puts the four numbers on the clipboard in this form. --shape lifts what lies under a closed shape instead. The document that comes out is still rectangular, as a PDF page is, and is the shape's own bounding box, with everything the shape does not cover painted away.

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.

{
  "page" : 1,
  "shape" : false,
  "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 "extract" on "/path/to/report.pdf" ¬
        options "--to reviewed.pdf --bounds 72,540,180,24"
end tell

tell application "CaseLeaf"
    perform "extract" on "/path/to/report.pdf" ¬
        options "--to reviewed.pdf --shape 72,540,300,540,72,300"
end tell

All the commands · Asking from a script · Contents