跳到主要内容
食谱编号197

排版食谱 · 第10章 · 输出与集成

精装书的书壳、护封和环衬

把一本平装书的书页再装成布面精装:另一个版本,有自己的ISBN,再由buildCover做出书壳、护封和前后两张环衬。

本页内容
输出
Canvas · PDF
难度
高级
Postext
已用Postext 1.92.0测试
需要≥ 1.92.0 · postext-pdf ≥ 1.92.0
许可证
更新于2026年11月23日
代码MIT · 文本CC BY 4.0

页码1 · 第39页,共41页

  • 英文样例:尚无中文版本
  • 成品尺寸120 × 190 mm
  • 1栏
  • Crimson Pro 11/15.2
  • Cormorant Garamond
  • Josefin Sans
  • 41页
  • 难度
  • Postext 1.92.0
  • 排版用时189 ms
  • 239行代码

简单来说

还是贝克尔的两篇传说,这回做成精装书:包住纸板的布面、套在外面的纸护封,以及粘在封面里侧的彩绘纸张。书页不变;每个版本有自己的展开图和ISBN。

成品一览

还是那本带勒口平装书里贝克尔的两篇传说,这次再装订一遍,做成120 × 190毫米的精装书。37页书页原样不动。这本书现在有两个版本,各有自己的装订方式和ISBN,精装版要交给装订厂四张展开图。书壳裱深绿色的布,封面和书脊上烫金印出书名和作者。护封上是那幅画、简介文字、条码和前后两个勒口。封面里侧是两张彩绘环衬:前面是杜罗河畔的索里亚,后面是第二篇传说里的那眼泉水。

这道食谱解答

  • 同一本书除了平装,怎样再做精装的封壳、护封和环衬?

简短回答

script.js · 第29–55行在完整代码中
// 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' } },
  } };

用料

类型
Crimson Pro, Cormorant Garamond, Josefin Sans(SIL OFL 1.1)
素材
  • 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, 原创)
  • The front endpaper: Soria above the Duero at dusk, with the Mountain of the Spirits (Generated With Diffusion Models, 原创)
  • The back endpaper: a spring among poplars on the slopes of the Moncayo by moonlight (Generated With Diffusion Models, 原创)

做法

#1 · 一个书芯,两个版本

代码就是上面的简短回答。两个版本读取同一个folio.paper和同一批排好的书页:37页,向上取整为三个16页的书帖,24张,每张厚240微米。平装版加上胶的余量,书脊6.3毫米。精装版再加上两块2毫米的纸板,书脊10.3毫米。每个版本有自己的ISBN,两个都是出版社号段里的示例号码,不属于任何一本书。书脊做成平背,因为不到6毫米厚的书芯太薄,没法起圆;换成case-round会再加3毫米,做成圆背。书壳用布面(cloth),因为画、文字和条码都已经在护封上,底下烫一个书名就够了。

#2 · 书壳:包边、书槽和飘口

script.js · 第545–562行在完整代码中
// 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);

平装书的封面按成品尺寸裁切,勒口在前口折进去。精装书的书壳是一层包住两块纸板的面料。每块纸板在书脊一侧比书页窄7毫米,在天头、地脚和前口比书页多出3毫米(飘口),所以是116 × 196毫米。每块纸板和书脊之间留一道7毫米的书槽,书壳在这里弯折。四周还有15毫米的包边翻折到纸板边上,所以布面的底色一直铺到286.3 × 226毫米的整张展开图。

每张展开图都用同一个config和同一份封面文字来做。书壳的设计来自cover.sheets.case,只有一层布面底色;文字来自标了sheet="case"的文本框:封面纸板和书脊上的书名、副书名和作者,用的case-样式就是护封的样式改成金色;封底纸板上放一个空文本框,布面上就不会出现内容简介。条码只印在护封上,收银台扫的就是它。

#3 · 护封沿用封面的设计和文字

script.js · 第59–81行在完整代码中
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') }));

护封在cover.sheets里没有自己的一项,所以用书本身的cover和不带sheet的文本框,段落样式和封面Markdown都与平装版相同;书壳的文本框在这里不用,护封的封面和书脊就从元数据里取文字。它的面板更宽:每块盖住一块纸板、书槽,再多3毫米折到纸板边上,一共126毫米。勒口宽到80毫米,是书页宽度的三分之二,也是护封的默认值。画铺满封面面板,一直到折线,条码在封底面板上,书店在那里扫码。

#4 · 两张环衬放在一个文档里

script.js · 第566–572行在完整代码中
// 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));

一张环衬有两页宽:一半粘在纸板上,另一半是可以翻动的扉页。前环衬粘在纸板上的那一半在左边,后环衬在右边。每张展开图246 × 196毫米,天头、地脚和外侧各有3毫米出血,折线处没有出血,那里有一条5毫米的胶条把它粘在书芯上。两幅画都让中间保持安静,因为折线从那里穿过。两张展开图尺寸相同,所以放进同一个文档,每页一张。每幅画都是对应环衬在cover.sheets里的设计,横跨两页。

完整食谱

沙盒
// ═══ 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.

组合好的script.js可以直接运行:把它粘贴到任何页面的模块脚本中,或在CodePen上打开这道食谱。 GitHub上的食谱文件夹 ↗ (在新标签页中打开)

变化

#印刷书壳,不用布面

把case从cover.sheets里删掉,书壳就用书本身的设计:夜色底子,画在封面纸板上。书壳自己的文本框照样把书名印成金色。

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

#做成圆背

书再厚一些,case-round会给书壳的书脊加3毫米,护封的书脊也跟着变宽。

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

常见问题

  • 在截取的页面列表里,展开图排在书页后面:书壳是第38页,护封第39页,环衬第40和41页。书多一页,这些编号都会跟着变。
  • 在精装书上,sheet="cover"既指书壳,也指平装书的封面;sheet="case"只指书壳。某张展开图自己的文本框只在这张图上替换同一区域的通用文本框,空的文本框就让这块区域留白。

致谢

文本
  • 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 · 公有领域
  • 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 · 公有领域
图片
  • The dust jacket: a ruined chapel under the Moncayo on All Souls’ Night, in oils · Generated With Diffusion Models · 原创
  • The front endpaper: Soria above the Duero at dusk, with the Mountain of the Spirits · Generated With Diffusion Models · 原创
  • The back endpaper: a spring among poplars on the slopes of the Moncayo by moonlight · Generated With Diffusion Models · 原创
字体
Crimson Pro (SIL OFL 1.1) · Cormorant Garamond (SIL OFL 1.1) · Josefin Sans (SIL OFL 1.1)
沙盒PDF