CaseLeaf

Handbook / The `pages` command

The pages command

An exhibit has to be inserted at the right place in a bundle and a cover sheet taken out.

Adds, removes or moves sheets. It is the one for assembling: putting an appendix in, taking a cover sheet out, getting an exhibit into the right order.

It works on the document you name, not on a copy: --remove, --insert, --blank and --move all rewrite it where it stands, and there is no way to ask them for a copy instead, so make one first if the original matters. The exception is --take, which lifts a sheet out into a file of its own and leaves the document alone.

How you run it

caseleaf pages report.pdf --remove 2

caseleaf pages report.pdf --remove 2,3

caseleaf pages report.pdf --move 3 --to 1

caseleaf pages report.pdf --insert other.pdf

caseleaf pages report.pdf --insert other.pdf --at 2

caseleaf pages report.pdf --take 2 --to page.pdf

caseleaf pages report.pdf --blank 2

caseleaf pages report.pdf --blank 2 --at 3 --size a4

What each part means

In full, every part it will take:

caseleaf pages <file> --remove 2[,3]
caseleaf pages <file> --move 3 --to 1
caseleaf pages <file> --insert <other.pdf> [--at 2]
caseleaf pages <file> --take 2 --to <page.pdf>
caseleaf pages <file> --blank 2 [--at 3] [--size a4]
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. This command writes to it, so keep a copy if the original matters.
--remove Which sheets to take out, as numbers separated by commas, for example 2,5,6. They are counted in the document as it stands now, not as it will be afterwards.
--move Which sheet to move, counting from 1. --to says where it lands, also counting from 1, in the order after the move.
--to What this means depends on what you asked for: with --move it is the sheet the page lands on, counting from 1, so --move 3 --to 1 brings the third sheet to the front; with --take it is the file to write the lifted sheet to. --remove, --insert and --blank change the document you named and want no --to at all.
--insert A document whose sheets to add, as a path, for example exhibit.pdf. All of its sheets go in; --at says where, and the document named is not changed.
--at Where they go. The end if left out. (optional)
--take Which sheet to lift out into a file of its own; --to names that file.
--blank How many empty sheets to add, as a number. --at says where they go and --size how big they are.
--size The paper size for sheets being added: a3, a4, a5, letter, legal or tabloid. Left out, the size set in Settings, and where nothing is set, whichever the region uses, so the same command gives A4 in Europe and Letter in the United States.

--remove takes those pages out. --move puts a page somewhere else; bookmarks and snapshots follow, and one on a removed page is dropped rather than pointed at its neighbour. --blank adds empty sheets to write on, at the end unless you say where; the size is the one in Settings unless --size names a3, a4, a5, letter, legal or tabloid.

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.

{
  "bookmarksLost" : 0,
  "bookmarksMoved" : 6,
  "lost" : [

  ],
  "pages" : 7,
  "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 "pages" on "/path/to/report.pdf" ¬
        options "--remove 2"
end tell

tell application "CaseLeaf"
    perform "pages" on "/path/to/report.pdf" ¬
        options "--move 3 --to 1"
end tell

tell application "CaseLeaf"
    perform "pages" on "/path/to/report.pdf" ¬
        options "--insert other.pdf"
end tell

tell application "CaseLeaf"
    perform "pages" on "/path/to/report.pdf" ¬
        options "--take 2 --to page.pdf"
end tell

tell application "CaseLeaf"
    perform "pages" on "/path/to/report.pdf" ¬
        options "--blank 2"
end tell

All the commands · Asking from a script · Contents