Pagecraft

bates-number

Bates numbering

Stamp one unbroken sequence of numbers across a whole set of files.

Reads
the PDFs in the production, in the order they should be numbered — application/pdf, 1 or more
Writes
any number of files — PDFs
Tool page
/bates-numbering

Example

Stamp a disclosure bundle with the continuous numbering a court asks for.

Given

  • disclosure.pdf — an ordinary PDF of 3 pages

From code

            import { loadDocument, runOperation } from '@pagecraft/core';

const disclosure = await loadDocument({ bytes, name: 'disclosure.pdf' });

const [output] = await runOperation('bates-number', [disclosure], {
  prefix: 'ACME-',
  start: 1,
  digits: 6,
});
          

From a shell

            pagecraft bates-number disclosure.pdf --prefix ACME- --start 1 --digits 6
          

What comes back

One PDF of 3 pages, containing “ACME-000001”.

This example is run by the test suite. If it stopped being true, the build would fail.

Options

prefix--prefix

string

Prefix

What comes before the number: a matter code, a party name.

Default: ''

suffix--suffix

string

Suffix

What comes after it, such as a confidentiality designation.

Default: ''

start--start

integer

Starting at

Default: 1

digits--digits

integer

Digits

The number is padded with leading zeros to this width.

Default: 6

position--position

string, one of

Position

Default: 'bottom-right'

  • top-left — Top left
  • top-center — Top centre
  • top-right — Top right
  • middle-left — Middle left
  • middle-center — Centre
  • middle-right — Middle right
  • bottom-left — Bottom left
  • bottom-center — Bottom centre
  • bottom-right — Bottom right

margin--margin

number

Margin

Default: 10

unit--unit

string, one of

Measured in

Default: 'mm'

  • mm — Millimetres
  • cm — Centimetres
  • in — Inches
  • pt — Points

font--font

string, one of

Typeface

Default: 'sans'

  • sans — Helvetica.
  • serif — Times.
  • mono — Courier.

bold--bold

boolean

Bold

Default: false

italic--italic

boolean

Italic

Default: false

fontFile--font-file

Uint8Array

Font file

A TrueType or OpenType font to set the text in. Needed for scripts the built-in fonts do not cover, unless the host supplies one.

size--size

number (pt)

Size

Default: 10

color--color

string, '#rrggbb'

Colour

Default: '#000000'

What it cannot do

  • Every page of every file carries a number, because an unbroken sequence is the whole point of one. To number part of a file, take those pages out of it first.
  • The number is drawn on top of the page, so a page whose content already reaches the corner is written over rather than reflowed.
  • Shaping and joining come from the font itself, and nothing reorders a line: text is drawn in the order it is given, so a line mixing right-to-left and left-to-right writing comes out in that order rather than in reading order.