Skip to main content
Recipe number 193

Cookbook · Chapter 10 · Output & integration

A peek-a-boo board book with holes in register

Four die-cut holes, placed with dieCuts where the next painting's telling part lies, a window that steps down to a smaller hole, rounded corners and a die line.

On this page
Postext
Tested with Postext 1.84.0
Needs ≥ 1.84.0 · postext-pdf ≥ 1.84.0
Licence
Updated 13 Nov 2026
Code MIT · Text CC BY 4.0
  • Trim 160 × 160 mm
  • 1 column
  • Andika 24/31
  • Fredoka
  • Nunito
  • 14 pages
  • Level
  • Postext 1.84.0
  • Laid out in 9 ms
  • 187 lines of code

In short

A cardboard picture book for toddlers. Each hole in a page shows a small piece of the next picture, the words make a guess, and turning the page shows what it really is.

What you'll build

Peek-a-boo! Who’s in the Garden?, a fourteen-page board book on a 160 mm square, its corners rounded on all four sides. Each painting has a hole, and the hole is cut exactly where the next painting keeps the part that fools the eye: the striped flank of a sleeping cat that could be a tiger, a sheep's wool that could be a cloud, a lantern that could be the moon. The cover's window is wider than the hole behind it, so the first look goes two pages deep. The words on the left make the guess; the turn of the page answers it. The press file carries the die line on a plate of its own.

This recipe answers

  • How do I cut holes through a book’s pages, each showing part of the next picture?
  • How do I send the die-maker a die line on its own plate in the PDF?

The short answer

script.js · lines 43–61in full code
// Each painting is cut where the next one's telling part lies: the cat's striped flank, the
// sheep's wool, the lantern's glow. The cover's window is wider than the hedge's hole and
// holds it, so from the cover you see the hedge, and through the hedge the cat. A hole cuts
// both sides of its leaf, mirrored on the verso, and the words there run round it.
const circle = (id, name, cx, cy, d) => ({ id, name, shape: 'circle', x: mm(cx - d / 2),
  y: mm(cy - d / 2), width: mm(d), height: mm(d), wrap: { gap: mm(4) } });
const dieCuts = {
  shapes: [
    circle('window', t({ en: 'Cover window', es: 'Ventana de la cubierta' }), 112, 68, 60),
    circle('hedge', t({ en: 'Gap in the hedge', es: 'Hueco del seto' }), 112, 60, 36),
    { id: 'knot', name: t({ en: 'Knothole', es: 'Nudo de la valla' }), shape: 'ellipse',
      x: mm(102), y: mm(48), width: mm(32), height: mm(40), wrap: { gap: mm(4) } },
    circle('peephole', t({ en: 'Barn-door peephole', es: 'Mirilla del granero' }), 91, 29, 20),
  ],
  // By position in the book: page 1 is the cover, 3 the hedge, 7 the fence, 11 the door.
  pages: [{ pages: '1', die: 'window' }, { pages: '3', die: 'hedge' },
    { pages: '7', die: 'knot' }, { pages: '11', die: 'peephole' }],
  corners: { radius: mm(9), edges: 'all' }, // board books are rounded on all four corners
};

The dies, and the pages they cut

Ingredients

Type
Andika, Fredoka, Nunito (SIL OFL 1.1)
Assets
  • cat.jpg
  • cover.jpg
  • door.jpg
  • fence.jpg
  • hedge.jpg
  • lantern.jpg
  • sheep.jpg
  • Cover painting: a cottage garden, a hedge, hollyhocks and a robin (Generated With Diffusion Models, original)
  • Page 3: the hedge (Generated With Diffusion Models, original)
  • Page 5: the ginger cat asleep (Generated With Diffusion Models, original)
  • Page 7: the wooden fence (Generated With Diffusion Models, original)
  • Page 9: the sheep (Generated With Diffusion Models, original)
  • Page 11: the barn door (Generated With Diffusion Models, original)
  • Page 13: Grandpa and his lantern at dusk (Generated With Diffusion Models, original)

Method

#1 · Holes where the next picture tells

The code is the short answer above. Each shape is placed from the trim's top-left corner and dieCuts.pages names the page it cuts, counted from the book's first page. Measure the hole on the painting it reveals, not on the page it is cut in: the hedge, the fence and the door are textures that take a hole anywhere, the cat and the lantern are not.

#2 · Paintings in register with the holes

script.js · lines 65–84in full code
// Each painting hangs from the trim and runs BLEED past it on every side, so the holes hit it
// in the same place on screen and in print. A picture's section drops the foot margin, so its
// design reaches the foot of the page; the words on the verso behind it, in the same section,
// start TOP down.
const SHEET = { width: mm(TRIM + 2 * BLEED), height: mm(TRIM + 2 * BLEED) }; // trim + bleed
const painting = { kind: 'image', id: 'painting', resourceId: '{attr.picture}', fit: 'cover',
  placement: at('page', 'top-left', -BLEED, -BLEED, SHEET) };
const full = (elements) => ({ enabled: true, minHeight: mm(TRIM - TOP), slot: { elements } });
const flush = { margins: { top: mm(TOP), bottom: mm(0), left: mm(INNER), right: mm(OUTER) } };
const title = { kind: 'text', id: 'title', content: '{titleText}', fontFamily: DISPLAY,
  fontWeight: 600, fontSize: pt(40), lineHeight: 1, color: col('accent'), align: 'left',
  placement: at('page', 'top-left', 62, 8, { width: mm(88) }) };
const headingStyles = [
  { id: 'cover', numbered: false, toc: false, ...flush, advancedDesign: full([painting, title]) },
  { id: 'picture', numbered: false, ...flush, breakBefore: { enabled: true, parity: 'odd' },
    advancedDesign: full([painting]) },
  // The back cover: the board printed dusk blue (the section's palette), the type in cream.
  { id: 'back', numbered: false, toc: false, breakBefore: { enabled: true, parity: 'even' },
    color: col('cream'), palette: { paper: palette.dusk } },
];

The holes are in trim millimetres, so every painting hangs from the trim and runs the bleed past it on every side, on screen and in print alike. The picture style drops only the foot margin: its design reaches the foot of the page, and the words on the verso behind it keep their 44 mm top margin, which lowers them under the top of the small holes.

#3 · The die line on its own plate

script.js · lines 96–99in full code
  // The die line is stroked on a Separation plate of its own ('Die'), overprinting, that the
  // press never inks. PDF/X-4 on coated stock: the board is printed on coated paper.
  print: { standard: 'pdfx4', outputProfile: 'fogra51', convertImages: false,
    dieLine: { output: 'page', ink: 'Die', width: pt(0.5) } },

The PDF prints each page whole and strokes the outline of every hole, and of each rounded leaf, on a Die separation that overprints and is never inked. convertImages: false keeps the paintings as RGB JPEGs tagged sRGB, which PDF/X-4 allows, so the file stays small.

#4 · The book in the hand

script.js · lines 122–128in full code
  folio: {
    tilt: 50, yaw: -32,
    paper: { type: 'board', shade: '#fbf5e8' },
    binding: { type: 'hardcover', cover: 'pages', coverMaterial: 'paper' },
    surface: { type: 'oak' },
    lighting: { environment: 'daylight', intensity: 1.05 },
  },

Folio cuts the holes through each leaf and shows the pages beneath with the walls of the cut, so the stepped window reads as depth. Board stock turns stiff, and the rounded corners are cut on every leaf.

#5 · Flat pages that look through

script.js · lines 242–252in full code
// renderPageToCanvas cuts the holes; `beneath` hands it the pages under them, painted here
// at a lower scale (the composite stretches them to the page), each with its own holes.
const under = new Map();
const beneath = (i) => {
  if (!under.has(i) && doc.pages[i]) {
    const canvas = document.createElement('canvas');
    under.set(i, canvas);
    renderPageToCanvas(doc.pages[i], doc, canvas, { scale: 1, beneath });
  }
  return under.get(i);
};

On the canvas a hole shows what is behind the canvas unless the renderer gets the pages beneath. beneath returns them by index, each painted with its own holes, so the cover shows the hedge and, through the hedge, the cat.

The whole recipe

Sandbox
// ═══ Postext Cookbook · Nº 193 · A peek-a-boo board book with holes in register ════════
// https://postext.dev/en/cookbook/peek-a-boo-board-book
// Code: MIT · Text: original (CC BY 4.0) · Paintings: generated with diffusion models
// Fonts: Andika, Fredoka, Nunito (SIL OFL 1.1) · Needs postext ≥ 1.84.0
//
// A fourteen-page board book for toddlers: on every other recto a hole is cut through the
// painting, and what shows through it is a scrap of the next picture. The words on the left
// make a guess from the scrap; the turned page shows what it really is. The leaves have
// rounded corners, the holes step down from the cover, and the PDF carries the die line.
import {
  buildDocumentWithFonts, renderPageToCanvas, registerResourceImage,
} from 'https://esm.sh/postext';
import { renderToPdf, decompressWoff2 } from 'https://esm.sh/postext-pdf';
import { createFolioFromDocument } from 'https://esm.sh/postext-folio';

const LANG = 'en'; // @lang: the language of the sample document ('en' | 'es')
const RECIPE = 'peek-a-boo-board-book';

// ─── 1 · Design ─────────────────────────────────────────────────────────────
// #region palette: a cream board, a robin red for the title and the guesses, a dusk blue
const palette = {
  ink: '#2a2420', // text: a warm near-black
  accent: '#b8432c', // the cover title and the guesses: the robin's breast
  paper: '#fbf5e8', // the board the words are printed on
  dusk: '#253a63', // the back cover, the blue of the last painting's sky
  cream: '#fff9ec', // type on the cover and the back
  muted: '#7a6f64', // the colophon
};
const col = (id) => ({ hex: palette[id], model: 'hex', paletteId: id });
const colorPalette = [
  ...Object.entries(palette).map(([id, hex]) => ({ id, name: id, value: { hex, model: 'hex' } })),
  { id: 'main-color', name: 'accent (defaults)', value: { hex: palette.accent, model: 'hex' } },
];
// #endregion
const [TRIM, BLEED] = [160, 3]; // mm: a square board book, and its bleed
const [TOP, FOOT, INNER, OUTER] = [44, 16, 18, 16]; // the words sit low, under the holes' tops
const [TEXT, DISPLAY, LABEL] = ['Andika', 'Fredoka', 'Nunito'];
const LEAD = 31; // pt: 24 pt type on a generous leading, for reading aloud
const at = (to, edge, x = 0, y = 0, size) => ({ anchor: { to, edge },
  offset: { x: mm(x), y: mm(y) }, ...(size && { size }) });

// #region answer: the dies, and the pages they cut
// Each painting is cut where the next one's telling part lies: the cat's striped flank, the
// sheep's wool, the lantern's glow. The cover's window is wider than the hedge's hole and
// holds it, so from the cover you see the hedge, and through the hedge the cat. A hole cuts
// both sides of its leaf, mirrored on the verso, and the words there run round it.
const circle = (id, name, cx, cy, d) => ({ id, name, shape: 'circle', x: mm(cx - d / 2),
  y: mm(cy - d / 2), width: mm(d), height: mm(d), wrap: { gap: mm(4) } });

The composed script.js runs as it is: paste it into any page’s module script, or open the recipe on CodePen. Recipe folder on GitHub ↗ (opens in a new tab)

Variations

#Round only the fore-edge corners

A trade picture book rounds the two corners away from the spine and keeps the spine square.

-  corners: { radius: mm(9), edges: 'all' }, // board books are rounded on all four corners
+  corners: { radius: mm(6), edges: 'fore' },

#Cut every leaf to a shape

An outline in viewBox units cuts every leaf to it, mirrored on the versos; it wins over the corners.

   corners: { radius: mm(9), edges: 'all' }, // board books are rounded on all four corners
+  outline: { d: 'M0 0.35 L0.5 0 L1 0.35 L1 1 L0 1 Z', viewBox: [1, 1] }, // a house

Credits

Text
  • The words of the board book · Postext Cookbook · CC BY 4.0
Images
  • Cover painting: a cottage garden, a hedge, hollyhocks and a robin · Generated With Diffusion Models · original
  • Page 3: the hedge · Generated With Diffusion Models · original
  • Page 5: the ginger cat asleep · Generated With Diffusion Models · original
  • Page 7: the wooden fence · Generated With Diffusion Models · original
  • Page 9: the sheep · Generated With Diffusion Models · original
  • Page 11: the barn door · Generated With Diffusion Models · original
  • Page 13: Grandpa and his lantern at dusk · Generated With Diffusion Models · original
Fonts
Andika (SIL OFL 1.1) · Fredoka (SIL OFL 1.1) · Nunito (SIL OFL 1.1)
SandboxPDF