CaseLeaf

Handbook / The `saveas` command

The saveas command

Somebody needs four pages of a hundred-page report, as images, for a presentation.

Writes the document, or the sheets you pick, in another format. It is the general way out to a picture: PNG, JPEG, HEIC, TIFF, JPEG-2000 or OpenEXR, one per sheet, or a PDF written differently, which is what the archival and network options are for. Picking sheets matters more than it sounds; most of the time what somebody needs is four pages of a hundred.

It does not write text or a Word file: docx makes the Word one, svg an outline drawing, and the words themselves come from read or find.

How you run it

caseleaf saveas report.pdf --to reviewed.pdf

What each part means

In full, every part it will take:

caseleaf saveas <file> --to <output> [--format pdf|png|jpeg|heic|tiff|jpeg2000|openexr] [--pages 1,2,3] [--quality 0-1] [--compression none|lzw|jpeg|packbits|zip] [--alpha] [--bits 16|32] [--pdfa] [--linearised] [--forscreen] [--asjpeg]
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.
--format What to write. The destination's own extension if left out, and this wins when the two disagree. An extension that names no format at all falls back to PDF.
--format What to write. The destination's own extension if left out, and this wins when the two disagree. An extension that names no format at all falls back to PDF.
--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.
--quality How hard to compress a picture, from 0, small and rough, to 1, large and faithful. 0.8 is the usual trade.
--compression How a TIFF is packed: none, lzw, jpeg,packbits or zip. lzw is lossless and widely read; jpeg is smaller and throws detail away. Ignored by every other format.
--alpha Leave whatever the sheet does not cover transparent, so a page dropped into a slide takes the slide's background rather than a white rectangle. Every format here carries it except jpeg, which cannot and ignores this.
--bits How many bits per channel an OpenEXR carries, 16 or 32. Ignored by every other format.
--pdfa Ask the system's PDF writer to mark the file as PDF/A, the form archives ask for. Read that wording: what it writes is the claim. This application does not embed fonts or convert colour and carries no validator of its own, so a file that has to hold up as an archival copy still wants checking with a tool made for it. Without it nothing about archiving is added.
--linearised Lay the file out so a reader can show the first sheet before the rest has arrived. That is what somebody opening it across a network needs. Without it the file is written in the ordinary order and a reader wants the whole of it before it can show anything. What the document says is the same either way.
--forscreen Re-encode the pictures at no more than 150 dots to the inch, plenty on a screen, and the single biggest saving on anything built from scans. Not for a file that will be printed.
--asjpeg Re-encode the pictures as JPEG. Smaller, and lossy: text inside a picture softens, so it is the wrong choice for a scanned document somebody will read.

PDF writes one document. Every other format writes one picture per sheet, each at the size the sheet is shown at. --pdfa, --linearised, --forscreen and --asjpeg are PDF's alone; --quality, --alpha, --compression and --bits belong to the picture formats that have them and are ignored by the rest.

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.

{
  "files" : 1,
  "format" : "pdf",
  "sheets" : 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 "saveas" on "/path/to/report.pdf" ¬
        options "--to reviewed.pdf"
end tell

All the commands · Asking from a script · Contents