CaseLeaf

Handbook / The `measure` command

The measure command

A site plan arrives and somebody has to say how wide the access road is without going there with a tape.

Says how large a rectangle is in real units, once you give it a length you already know. It is for drawings: a plan, an elevation, a site layout, where what is on the page is a known fraction of something real. Without that known length it has nothing to work from, which is why --scale is required every time.

You get more than the one number you drew for. The answer carries the width, the height, the diagonal, the perimeter and the area, all in the unit asked for, so a rectangle put round a room answers how wide and how much floor in the same breath.

How you run it

caseleaf measure report.pdf --bounds 72,540,180,24 --scale 180=180mm

caseleaf measure report.pdf --bounds 72,540,180,24 --scale 180=180mm --page 1 --in mm

What each part means

In full, every part it will take:

caseleaf measure <file> --bounds x,y,w,h --scale <points>=<length><unit> [--page <n>] [--in <unit>]
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.
--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".
--scale What is already known, as points=length: 144=3m means a line 144 points long on the sheet is three metres in the world. Everything else is worked out from it.
--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.
--in The unit to answer in: mm, cm, m, km, or in, ft, yd, mi. Left out, the unit the scale was given in, so --scale 144=3m --in ft is how you calibrate in one and read in the other.

The scale is a line of known length: 144=3m is a hundred and forty-four points drawn along something three metres long. Without one the answer is in points, which is useless on a plan.

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.

{
  "area" : 4320,
  "diagonal" : 181.59295140505867,
  "height" : 24,
  "page" : 1,
  "perimeter" : 408,
  "ratio" : 2.8346456692913389,
  "unit" : "mm",
  "width" : 180
}

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 "measure" on "/path/to/report.pdf" ¬
        options "--bounds 72,540,180,24 --scale 180=180mm"
end tell

tell application "CaseLeaf"
    perform "measure" on "/path/to/report.pdf" ¬
        options "--bounds 72,540,180,24 --scale 180=180mm --page 1 --in mm"
end tell

All the commands · Asking from a script · Contents