PDFPipe

Getting paid / Direct debit mandate

A direct debit mandate laid out to be completed by hand

A form section collecting account details, a signature and a date, to be filled in on paper and returned.

Why this block is harder than it looks

This is a form rather than a document, which inverts every layout instinct in the cluster: the important measurement is not how the type looks but how much room a pen needs, and the fields are sized for handwriting rather than for the values they will hold. An account number written by hand needs a character box per digit or it becomes illegible, which is a layout most generated documents never produce. And the mandate has fixed wording that must be present and unaltered, so the space left for it is not negotiable.

The decisions that make it work

Reasons rather than a description of the code. Each of these is a choice that has a wrong answer, and the wrong answer is usually the default.

  • Use character boxes for account and sort code fields: one box per digit, at least 5mm wide and 7mm tall. Handwritten digits in a single long box are routinely misread.
  • Size every writing line at 8mm minimum, and name and address fields at two lines rather than one.
  • Print the mandatory wording in full at its required size and lay the fields around it, rather than fitting the wording into what is left.
  • Put the signature and date at the bottom in a block that cannot be separated from the wording above it.
  • Leave the boxes white with a thin border. A tinted form field is harder to write on and harder to read once written on.
  • Keep the whole mandate on one page. A mandate signed on a page whose account fields are on the previous sheet is not a mandate.

The fragment

Markup and the CSS it needs, and nothing else. It expects a document that already has a page rule and a base stylesheet, so paste it into one rather than opening it on its own.

html
<section class="mandate">
  <p class="wording">Please pay the originator named above from the account
    detailed in this instruction, subject to the safeguards of the scheme.</p>

  <label class="field">
    <span>Account number</span>
    <span class="boxes">
      <i></i><i></i><i></i><i></i><i></i><i></i><i></i><i></i>
    </span>
  </label>

  <label class="field wide">
    <span>Account holder name</span>
    <span class="line"></span>
  </label>

  <div class="sign-row">
    <label class="field wide"><span>Signature</span><span class="line tall"></span></label>
    <label class="field"><span>Date</span><span class="line tall"></span></label>
  </div>
</section>

<style>
  .mandate { break-inside: avoid; }       /* never split a mandate */
  .mandate .wording { font-size: 8.5pt; line-height: 1.45; margin: 0 0 10pt; }
  .mandate .field { display: block; margin-bottom: 8pt; }
  .mandate .field > span:first-child {
    display: block;
    font-size: 7.5pt;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #555;
    margin-bottom: 2mm;
  }
  .mandate .boxes { display: flex; gap: 1.5mm; }
  .mandate .boxes i {
    display: block;
    width: 5.5mm; height: 7mm;            /* one box per digit */
    border: 0.5pt solid #999;
  }
  .mandate .line {
    display: block;
    height: 8mm;
    border-bottom: 0.5pt solid #999;
  }
  .mandate .line.tall { height: 12mm; }
  .mandate .sign-row { display: grid; grid-template-columns: 2fr 1fr; gap: 8mm; }
</style>

What breaks when it is built the obvious way

Collecting the account number in one long ruled box. People write digits at their own spacing, the digits run together, and the transcription error rate on a hand-filled account number in a single box is the reason character boxes exist at all.

How to prove it survived pagination

Print it and fill it in with a ballpoint, then hand it to somebody else and ask them to read the account number back. Every digit they hesitate on is a box that is too small or too close to its neighbour.

Where it sits in a finished document

This page is one block. The document it belongs to has a page rule, a base stylesheet, a header and everything else around it, and repeating all of that here would make thirty pages that say the same thing. The rent receipt template is a complete file with this block already in it, so take that and change the fragment rather than assembling one from parts. The property doing most of the work here is covered on its own page, with the support caveats that belong there rather than here.

Frequently asked

Will this fragment work on its own?

Not as a whole document. It has no page rule, no margins and no base type, because those belong to the document rather than to the block, and duplicating them in every fragment would mean thirty copies to keep in step. Paste it into a template that already has them.

Why does it look right in a browser and wrong in the PDF?

Because a browser window is one continuous surface and a document is a stack of fixed rectangles. Nothing in a scrolling view exercises a page boundary, so every break rule in the fragment is inert until the content is paginated. Render the real thing with enough content to cross two or three boundaries, then look.

Do I need a special option on the render request for this?

No. Everything on this page is CSS and markup, which is your side of the boundary. What the render has to give you is a real page size with real margins, and after that the layout is decided by the stylesheet.

Other parts of a document

The blocks that sit next to this one, and one from the next group along so you are not sealed inside a single kind of problem.

Paste the fragment into the playground inside a page rule and see what it does at a real page size. That is the only way any of this gets confirmed.