Skip to main content
Recipe number 197

Cookbook · Chapter 10 · Output & integration

A hardcover's case, dust jacket and endpapers

The pages of a paperback bound again as a cloth hardcover: a second version with its own ISBN, and buildCover makes the case, the jacket and both endpapers.

On this page
Output
Canvas · PDF
Postext
Tested with Postext 1.92.0
Needs ≥ 1.92.0 · postext-pdf ≥ 1.92.0
Licence
Updated 23 Nov 2026
Code MIT · Text CC BY 4.0

p. 1 · 39 of 41

  • Trim 120 × 190 mm
  • 1 column
  • Crimson Pro 11/15.2
  • Cormorant Garamond
  • Josefin Sans
  • 41 pages
  • Level
  • Postext 1.92.0
  • Laid out in 189 ms
  • 239 lines of code

In short

The same two Spanish legends as a hardback: the cloth over the boards, the paper jacket round it and the painted sheets glued inside the covers. The pages stay the same; each version gets its own sheets and ISBN.

What you'll build

The two Bécquer legends of the paperback with flaps, bound a second time as a 120 × 190 mm hardcover. The 37 pages stay as they are. The book now has two versions, each with its own binding and ISBN, and the hardcover has four sheets for the binder. The case is covered in dark green cloth, with the title and author stamped in gold on the front board and the spine. The dust jacket carries the painting, the blurb, the barcode and the two flaps. Two painted endpapers sit inside the boards: Soria above the Duero at the front, the spring of the second legend at the back.

This recipe answers

  • How do I make a hardcover's case, dust jacket and endpapers for the same book as its paperback?

The short answer

script.js · lines 29–55in full code
// The paperback is Nº 196's, on the printer's own profile. The hardcover takes the built-in
// flat-spine case; `flaps` on a case means a dust jacket, and `caseMaterial: 'cloth'` a case
// covered in cloth and stamped, under the jacket. Spines, boards and turn-ins come from the
// laid-out pages on the paper of `folio.paper`.
const production = {
  bindings: [{ id: 'pur-flaps', name: 'PUR perfect binding, 60 mm flaps', style: 'perfect',
    signature: 16, measures: { flapWidth: 60, bleed: 3, spineAllowance: 0.5 } }],
  versions: [
    { id: 'paperback', name: t({ en: 'Paperback', es: 'Rústica' }), binding: 'pur-flaps',
      flaps: true, isbn: '978-84-0000-196-4', isbnAddOn: '90000' },
    { id: 'hardcover', name: t({ en: 'Hardcover', es: 'Cartoné' }), binding: 'case-flat',
      flaps: true, caseMaterial: 'cloth', isbn: '978-84-0000-197-1', isbnAddOn: '90000' },
  ],
};
// 100 g/m² bulky cream wove at a bulk of 2.4: each leaf is 100 × 2.4 = 240 µm thick.
const folio = { paper: { type: 'bookWove', grammage: 100, bulk: 2.4, shade: '#f7f1e3' } };
// The book's cover design (the paperback's, the jacket's): a night ground and the painting
// on the front panel, into the bleed, whatever the panel's width. `sheets` gives the
// hardcover's other sheets a design of their own: the case its cloth, each endpaper its
// painting across both leaves.
const cover = { background: col('night'), verticalAlign: { back: 'middle' },
  image: { resourceId: 'moncayo', area: 'front', focus: { x: 0.5, y: 0.4 } },
  sheets: {
    case: { background: col('cloth') },
    endpaperFront: { image: { resourceId: 'soria' } },
    endpaperBack: { image: { resourceId: 'fuente' } },
  } };

Two versions over the same pages, each with its binding and its ISBN

Ingredients

Type
Crimson Pro, Cormorant Garamond, Josefin Sans (SIL OFL 1.1)
Assets
  • fuente-1300.jpg
  • moncayo-1100.jpg
  • soria-1300.jpg
  • The dust jacket: a ruined chapel under the Moncayo on All Souls’ Night, in oils (Generated With Diffusion Models, original)
  • The front endpaper: Soria above the Duero at dusk, with the Mountain of the Spirits (Generated With Diffusion Models, original)
  • The back endpaper: a spring among poplars on the slopes of the Moncayo by moonlight (Generated With Diffusion Models, original)

Method

#1 · One book block, two versions

The code is the short answer above. Both versions read the same folio.paper and the same laid-out pages: 37 pages, rounded up to three signatures of 16, 24 leaves of 240 µm each. The paperback adds the glue allowance and gets a 6.3 mm spine. The hardcover adds both 2 mm boards as well, so its spine is 10.3 mm. Each version has its own ISBN, both sample numbers from a publisher block assigned to no book. The case has a flat spine because a block under 6 mm thick is too thin to round; case-round would add 3 mm and round it. The case is cloth because the jacket already carries the picture, the texts and the barcode. Under it, a stamped title is enough.

#2 · The case: turn-in, joints and squares

script.js · lines 545–562in full code
// One call per sheet, with the same config and the same cover text: each sheet takes its
// design from `cover.sheets` (the jacket, the book's) and the frames meant for it. The
// barcode goes on the jacket alone, the sheet a till scans.
const built = {};
for (const sheet of ['cover', 'jacket', 'endpaperFront', 'endpaperBack']) {
  const made = buildCover({ config, sheet, pages: book.pages, version: 'hardcover',
    markdown: coverText, metadata: book.metadata, resources });
  if (!('config' in made)) throw new Error(made.issues.map((i) => i.kind).join(', '));
  // The barcode's digits name OCR-B, which no font server has: set in the label face.
  for (const [id, bytes] of Object.entries(made.files)) {
    await loadSvg(id, new TextDecoder().decode(bytes)
      .replace(/font-family="[^"]*"/g, 'font-family="Josefin Sans"'));
  }
  built[sheet] = made;
}
const sheetDoc = (b) => buildDocumentWithFonts(b.content, b.config, kitFonts(FONTS));
const caseDoc = await sheetDoc(built.cover);
const jacketDoc = await sheetDoc(built.jacket);

A paperback cover is cut to the trim and its flaps fold in at the fore-edges. A case is a covering wrapped round two boards. Each board is cut 7 mm narrower than the page at the spine and stands 3 mm proud of the pages at head, foot and fore-edge (the squares), so it measures 116 × 196 mm. Between each board and the spine runs a 7 mm joint, where the cover bends. Round the whole piece a 15 mm turn-in folds over the board edges, which is why the cloth ground runs out to a 286.3 × 226 mm sheet.

Each sheet is built from the same config and the same cover text. The case takes its design from cover.sheets.case, a bare cloth ground, and its lines from the frames marked sheet="case": title, subtitle and author on the front board and the spine, in case- styles that are the jacket's in gold, and an empty frame on the back board, which keeps the blurb off the cloth. The barcode prints on the jacket only, the sheet a till scans.

#3 · The jacket reuses the cover's design and text

script.js · lines 59–81in full code
const style = (id, fontFamily, size, lead, color, extra) => ({ id, fontFamily, fontSize: pt(size),
  lineHeight: pt(lead), color, italicColor: color, firstLineIndent: mm(0), textAlign: 'left',
  hyphenation: false, ...extra });
const caps = (tracking) => ({ fontWeight: 600, textTransform: 'uppercase',
  letterSpacing: pt(tracking) });
const coverStyles = [
  style('cover-title', 'Cormorant Garamond', 40, 40, col('bone'), { fontWeight: 600,
    textAlign: 'center', marginTop: mm(12) }),
  style('cover-subtitle', 'Cormorant Garamond', 15, 19, col('bone'), { italic: true,
    textAlign: 'center' }),
  style('cover-author', 'Josefin Sans', 8.5, 11, col('gold'), { ...caps(1.8),
    textAlign: 'center', marginTop: pt(16) }),
  style('cover-spine', 'Josefin Sans', 7.5, 9, col('bone'), { ...caps(1.2), textAlign: 'center' }),
  style('cover-blurb', 'Crimson Pro', 10.5, 14.5, col('bone'), { marginBottom: pt(7) }),
  style('cover-note', 'Crimson Pro', 10.5, 14.5, col('gold'), { italic: true }),
  style('flap-head', 'Josefin Sans', 7.5, 10, col('gold'), caps(1.4)),
  style('flap-text', 'Crimson Pro', 9.6, 13.2, col('bone'), { marginTop: pt(5) }),
];
// The case's frames (`sheet="case"` in the cover text) set the jacket's lines in gold, the
// colour the cloth is stamped in.
const stamped = coverStyles.filter((s) => /title|subtitle|author|spine/.test(s.id))
  .map((s) => ({ ...s, id: s.id.replace('cover-', 'case-'), color: col('gold'),
    italicColor: col('gold') }));

The jacket has no entry in cover.sheets, so it takes the book's cover and the frames with no sheet, with the paragraph styles and cover Markdown the paperback uses; its front and spine are filled from the metadata, since the case's frames are left out there. Its panels are wider: each covers a board, the joint and 3 mm more to fold round the board's edge, 126 mm in all. Its flaps grow to 80 mm, two thirds of the page width, which is the default for a jacket. The painting fills the front panel up to its fold, and the barcode sits on the back panel, where a bookseller scans it.

#4 · Two endpapers in one document

script.js · lines 566–572in full code
// Both endpapers are the size of two pages: one document holds them, a page each, the
// back's template renamed so the two templates do not share an id.
const [ef, eb] = [built.endpaperFront, built.endpaperBack];
const back = { ...eb.config.pageTemplates.at(-1), id: 'endpaper-back' };
const endpapers = await buildDocumentWithFonts({ ...ef.content, markdown: `${ef.content.markdown}`
  + `\n\n${eb.content.markdown.replace('postext-cover', back.id)}` },
{ ...ef.config, pageTemplates: [...ef.config.pageTemplates, back] }, kitFonts(FONTS));

An endpaper is two pages wide: the pastedown is glued to the board and the flyleaf turns like a page. At the front the pastedown is on the left, and at the back it is on the right. Each sheet is 246 × 196 mm, with 3 mm of bleed at head, foot and the outer edges and none at the fold, where a 5 mm glue strip holds it to the block. Both paintings keep their middles quiet, since the fold runs through them. The two sheets have one size, so one document holds them, a page each. Each painting is its endpaper's design in cover.sheets, laid across both leaves.

The whole recipe

Sandbox
// ═══ Postext Cookbook · Nº 197 · A hardcover's case, dust jacket and endpapers ═══
// https://postext.dev/en/cookbook/hardcover-jacket-and-endpapers
// Code: MIT · Text: Bécquer, tr. C. F. & K. L. Bates (public domain) · Art: diffusion models
// Fonts: Crimson Pro, Cormorant Garamond, Josefin Sans (SIL OFL 1.1) · Needs postext ≥ 1.92.0
//
// The pages of Nº 196 bound two ways: the paperback with flaps, and a cloth hardcover in a
// dust jacket with painted endpapers. Each version has its binding and its ISBN; buildCover
// makes each sheet of the hardcover from the same laid-out pages.
import {
  buildDocumentWithFonts, renderPageToCanvas, registerResourceImage, inlineSvgFonts,
} from 'https://esm.sh/postext';
import { buildCover } from 'https://esm.sh/postext/production';
import { renderToPdf, decompressWoff2 } from 'https://esm.sh/postext-pdf';

const LANG = 'en'; // @lang: the language of the sample document ('en' | 'es')
const RECIPE = 'hardcover-jacket-and-endpapers';

// ─── 1 · Design ─────────────────────────────────────────────────────────────
// The last four colours are the covers': the jacket's night, gold and bone, the case's cloth.
const palette = { ink: '#25221e', accent: '#86472a', muted: '#6b645a', paper: '#fbf7ee',
  night: '#16242a', gold: '#c99b4e', bone: '#eee5d1', cloth: '#22362f' };
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' } },
];

// #region answer: two versions over the same pages, each with its binding and its ISBN
// The paperback is Nº 196's, on the printer's own profile. The hardcover takes the built-in
// flat-spine case; `flaps` on a case means a dust jacket, and `caseMaterial: 'cloth'` a case
// covered in cloth and stamped, under the jacket. Spines, boards and turn-ins come from the
// laid-out pages on the paper of `folio.paper`.
const production = {
  bindings: [{ id: 'pur-flaps', name: 'PUR perfect binding, 60 mm flaps', style: 'perfect',
    signature: 16, measures: { flapWidth: 60, bleed: 3, spineAllowance: 0.5 } }],
  versions: [
    { id: 'paperback', name: t({ en: 'Paperback', es: 'Rústica' }), binding: 'pur-flaps',
      flaps: true, isbn: '978-84-0000-196-4', isbnAddOn: '90000' },
    { id: 'hardcover', name: t({ en: 'Hardcover', es: 'Cartoné' }), binding: 'case-flat',
      flaps: true, caseMaterial: 'cloth', isbn: '978-84-0000-197-1', isbnAddOn: '90000' },
  ],
};
// 100 g/m² bulky cream wove at a bulk of 2.4: each leaf is 100 × 2.4 = 240 µm thick.
const folio = { paper: { type: 'bookWove', grammage: 100, bulk: 2.4, shade: '#f7f1e3' } };
// The book's cover design (the paperback's, the jacket's): a night ground and the painting
// on the front panel, into the bleed, whatever the panel's width. `sheets` gives the
// hardcover's other sheets a design of their own: the case its cloth, each endpaper its
// painting across both leaves.

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

Drop case from cover.sheets and the case takes the book's design: the night ground and the painting on the front board. Its own frames still set the title in gold.

   sheets: {
-    case: { background: col('cloth') },
     endpaperFront: { image: { resourceId: 'soria' } },

#Round the spine

On a thicker book, case-round adds 3 mm to the case spine and the jacket's spine grows with it.

-    { id: 'hardcover', name: t({ en: 'Hardcover', es: 'Cartoné' }), binding: 'case-flat',
+    { id: 'hardcover', name: t({ en: 'Hardcover', es: 'Cartoné' }), binding: 'case-round',

Pitfalls

  • The sheets come after the book's pages in the captured list: the case at 38, the jacket at 39, the endpapers at 40 and 41. Add a page to the book and every number moves.
  • On a hardcover, sheet="cover" names the case as well as a paperback's cover; sheet="case" names the case alone. A frame of a sheet's own replaces the shared frame of that zone on that sheet only, so an empty one leaves the zone bare there.

Credits

Text
  • The Spirits’ Mountain and The Emerald Eyes, translated by Cornelia Frances Bates and Katharine Lee Bates, from Romantic Legends of Spain (1909), Project Gutenberg eBook #50044 · Gustavo Adolfo Bécquer · public domain
  • El monte de las ánimas and Los ojos verdes, from the Obras (Madrid, Fernando Fe, 1885) as transcribed on Wikisource, accents modernised · Gustavo Adolfo Bécquer · public domain
Images
  • The dust jacket: a ruined chapel under the Moncayo on All Souls’ Night, in oils · Generated With Diffusion Models · original
  • The front endpaper: Soria above the Duero at dusk, with the Mountain of the Spirits · Generated With Diffusion Models · original
  • The back endpaper: a spring among poplars on the slopes of the Moncayo by moonlight · Generated With Diffusion Models · original
Fonts
Crimson Pro (SIL OFL 1.1) · Cormorant Garamond (SIL OFL 1.1) · Josefin Sans (SIL OFL 1.1)
SandboxPDF