CaseLeaf

Handbook / The `svg` command

The svg command

A page has to go into a web page and a printed report, at sizes nobody has decided yet.

Writes a sheet as an outline drawing. It is for putting a page into something else: a slide, a report, a web page, at a size nobody has chosen yet, which a picture cannot survive and an outline can.

How you run it

caseleaf svg report.pdf --page 1 --bounds 72,540,180,24

caseleaf svg report.pdf --page 1 --bounds 72,540,180,24 --to output.svg

What each part means

In full, every part it will take:

caseleaf svg <file> --page <n> --bounds x,y,w,h [--to <output.svg>]
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.
--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.
--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".
--to Where to write the drawing, as a path ending .svg, for example figure.svg. Left out, the SVG is printed, which is what you want when something else is going to embed 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" : 672,
  "svg" : "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" width=\"53.76pt\" height=\"16.8pt\" viewBox=\"0 0 53.76 16.8\">\n<defs>\n<path id=\"g0\" d=\"M 0.08 0 L 0.52 0 L 0.52 0.7 L 0.08 0.7 Z\"/>\n<path id=\"g1\" d=\"M 0.08 0 L 0.52 0 L 0.52 0.36 L 0.08 0.36 Z\"/>\n</defs>\n<g transform=\"translate(-77.92 561.8) scale(1 -1)\">\n<use href=\"#g0\" transform=\"matrix(24 0 0 24 76 545)\" fill=\"#000000\"/>\n<use href=\"#g1\" transform=\"matrix(24 0 0 24 90.4 545)\" fill=\"#000000\"/>\n<use href=\"#g0\" transform=\"matrix(24 0 0 24 104.8 545)\" fill=\"#000000\"/>\n<use href=\"#g1\" transform=\"matrix(24 0 0 24 119.2 545)\" fill=\"#000000\"/>\n</g>\n</svg>"
}

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

tell application "CaseLeaf"
    perform "svg" on "/path/to/report.pdf" ¬
        options "--page 1 --bounds 72,540,180,24 --to output.svg"
end tell

All the commands · Asking from a script · Contents