跳到主要内容
食谱编号191

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

牛皮纸上印白墨的面包店菜单

把不透明白当作专色印在牛皮纸上:棕色卡纸上的白字,棕色文字下面垫的白卡,以及从绿色色块里镂空出来的白字。

本页内容
输出
Canvas · PDF
难度
高级
Postext
已用Postext 1.85.1测试
需要≥ 1.85.1 · postext-pdf ≥ 1.85.1
许可证
更新于2026年11月13日
代码MIT · 文本CC BY 4.0
  • 英文样例:尚无中文版本
  • 成品尺寸148 × 210 mm
  • 1栏
  • Lora 9.6/13.2
  • Alfa Slab One
  • 4页
  • 难度
  • Postext 1.85.1
  • 排版用时60 ms
  • 190行代码

简单来说

一份印在棕色牛皮卡纸上的面包店菜单。店名和标题用白色油墨印,棕色纸上能看到白色,是因为印刷厂把它当作额外的一种油墨加印上去。印刷文件把白色单独放在一块印版上。

成品一览

Horno Alto的菜单,这是一家虚构的乡村面包店:一张对折一次的A5棕色牛皮卡纸,共四页。牛皮纸本身没有白色,所以卡片上的每一处白都是印刷厂加印的油墨:直接印在棕色上的店名和栏目标题,三幅水粉画下面的白色衬板,以及印着营业时间的那张白卡。价格靠制表位对齐,前面拉一条点线,用四色印的深棕色。咖啡那一页有一块绿色色块,当日出炉的面包用白字印在上面,白字是从绿色里镂空的。Folio把菜单摆在日光下的一张橡木柜台上。

这道食谱解答

  • 怎样在牛皮纸上印白色,既印文字,也垫在彩色下面?

简短回答

script.js · 第20–35行在完整代码中
// The paper is a colour that prints no ink: the screen and Folio paint kraft, and no plate
// gets a dot of it. Because it is not white, the preflight knows the white ink shows on it.
// The white is a spot ink with the white finish: its own plate, laid down before the others.
const kraft = { hex: '#c19a6b', model: 'cmyk', cmyk: { c: 0, m: 0, y: 0, k: 0 } };
const WHITE = { name: 'Opaque White', cmyk: { c: 0, m: 0, y: 0, k: 0 } };
// A white ink overprints by default: laid under the colours, it must not cut holes in them.
const white = { hex: '#f7f4ee', model: 'spot', spot: { ...WHITE, finish: { kind: 'white' } } };
const PRINT = { standard: 'pdfx4', outputProfile: 'fogra52', convertImages: false,
  inks: [{ name: 'Opaque White', aliases: ['White'], finish: { kind: 'white' } }] };

// White type on a green panel must knock the green out.
// White printed under the green is hidden by it. For white type on a colour, the type must cut
// its shape out of the colour, so this white says overprint: false. Its hex differs by one
// step from the other white, since the PDF tells colours apart by hex; both print on one plate.
const whiteOut = { hex: '#f6f3ed', model: 'spot',
  spot: { ...WHITE, finish: { kind: 'white' }, overprint: false } };

用料

类型
Alfa Slab One, Lora(SIL OFL 1.1)
素材
  • coffee-600.jpg
  • loaf-700.jpg
  • pastries-900.jpg
  • A sourdough loaf, on the cover (Generated With Diffusion Models, 原创)
  • Three pastries (Generated With Diffusion Models, 原创)
  • A cup of coffee (Generated With Diffusion Models, 原创)

做法

#1 · 纸是牛皮纸,白是一种油墨

代码就是上面的简短回答。纸张是一个用CMYK全0定义的调色板颜色:屏幕和Folio会画出牛皮纸,但没有任何印版去印它。白色是带白墨工艺的专色(工艺),在油墨表里命名为Opaque White,也就是将来告诉印刷厂的名字。PDF/X-4文件把它放进单独的Separation,与四块四色印版并列。它在屏幕上的hex比#ffffff低一级,这样工艺遮罩就能分清这是油墨还是一张白纸。

#2 · 白色直接印在棕色上

script.js · 第63–70行在完整代码中
// The mount is a box in the white, the painting a picture over it. The white goes down first
// on press and runs on under the whole painting, so its light tones print on white.
const mount = (x, y, w, h, extra) => [
  { kind: 'box', id: 'mount', style: { backgroundColor: col('white') },
    placement: at('page', 'top-left', x, y, { width: mm(w), height: mm(h) }) },
  { kind: 'image', id: 'photo', resourceId: '{attr.photo}', fit: 'cover', ...extra,
    placement: at('page', 'top-left', x + 4, y + 4, { width: mm(w - 8), height: mm(h - 8) }) },
];

店名、栏目标题和内页的标题都是白色文字,字体用Alfa Slab One。白墨的遮盖力不如黑墨:细笔画会透出底下的棕色,所以12 pt以上的粗衬线字体还能看清,而细的衬线体就会发米黄。衬板是同一种白色的方框,每一边都比画作大4 mm。白色不只在画作四周,也一直铺到整幅画作下面,所以画里的浅色印在白色上,而不是印在棕色上。

#3 · 彩色压在白色上

营业时间印在一张白墨的卡片上,用的是菜单正文的深棕色。白墨默认叠印,棕色也设成了叠印(调色板颜色上的overprint: true),所以上机时棕色落在白色上面,而不是把自己的字形从白色里挖掉。

#4 · 白色压在彩色上:镂空

script.js · 第114–126行在完整代码中
const calloutStyles = [
  { id: 'bake', background: col('green'), marginTop: pt(LEAD), marginBottom: pt(0),
    padding: { top: mm(4), right: mm(5), bottom: mm(4), left: mm(5) },
    body: { fontFamily: SERIF, fontSize: pt(BODY), lineHeight: pt(LEAD), color: col('whiteOut'),
      boldColor: col('whiteOut'), italicColor: col('whiteOut'), textAlign: 'left',
      firstLineIndent: pt(0) } },
  // The hours: brown type on a card of white ink, the colour printed over the white.
  { id: 'hours', background: col('white'), marginTop: pt(LEAD), marginBottom: pt(0),
    padding: { top: mm(4), right: mm(5), bottom: mm(4), left: mm(5) },
    body: { fontFamily: SERIF, fontSize: pt(BODY), lineHeight: pt(LEAD), color: col('ink'),
      boldColor: col('ink'), textAlign: 'left', firstLineIndent: pt(0),
      tabStops: [{ position: 'end', align: 'end' }] } },
];

印刷机先印白,再把彩色印在上面,所以绿色色块上的白字会被绿色盖住。色块上的文字改用同一块印版上的第二种白,并设置overprint: false:文字把自己的形状从绿色里镂空,白色再把它填满。两种白的hex差一级,因为PDF是按hex区分颜色的。

#5 · 价格靠制表位对齐

script.js · 第106–110行在完整代码中
const dish = { id: 'dish', name: 'Dish', textAlign: 'left',
  tabStops: [{ position: 'end', align: 'end', leader: '. ' }],
  spaceBetween: pt(LEAD / 3), marginTop: pt(LEAD / 2) };
// The story on the back: half a line between paragraphs.
const story = { id: 'story', name: 'Story', spaceBetween: pt(LEAD / 2) };

每一栏是一个使用菜品样式的:::paragraphs组;价格前的:tab把它推到行宽末端,并用点线一直引到价格,和小酒馆菜单里一样。

#6 · 印前检查怎么说

script.js · 第274–282行在完整代码中
// A white ink on white paper prints nothing you can see, and the preflight warns of it
// (whiteInkOnWhite). On kraft it does not fire; the findings left say which special ink the
// job carries and that the press lays the white first.
const findings = preflightDocument(doc);
const report = document.createElement('p');
report.textContent = `Preflight: ${findings.map((f) => f.kind === 'inkPressOrder'
  ? `inkPressOrder (first: ${f.first.join(', ')})` : `${f.kind}${f.ink ? ` (${f.ink})` : ''}`)
  .join('; ') || 'no findings'}`;
document.querySelector(`[data-postext-pdf="${RECIPE}.pdf"]`).after(report);

当白墨落在纸张为白色或未设置的页面上时,preflightDocument会给出whiteInkOnWhite警告,因为在那里它什么也显示不出来。在牛皮纸上它不会报警,下载按钮下方那一行列出剩下的提示:白色作为特殊油墨(spotInkFinish),以及先印白的印刷顺序(inkPressOrder)。

#7 · Folio把菜单摆在柜台上

script.js · 第130–136行在完整代码中
const folio = {
  tilt: 20, yaw: -12,
  paper: { type: 'cardStock', grammage: 250, texture: 'felt', shade: kraft },
  binding: { type: 'folded', cover: 'pages' },
  surface: { type: 'oak' },
  lighting: { environment: 'daylight', intensity: 1.1 },
};

Folio画白色时会盖住纸张的底色,就像真的油墨一样;带毛毡纹理的卡纸让那片棕色看起来就是牛皮纸。

完整食谱

沙盒
// ═══ Postext Cookbook · Nº 191 · A bakery menu in white ink on kraft ═════════════════════
// https://postext.dev/en/cookbook/white-ink-kraft-menu
// Code: MIT · Text: original (CC BY 4.0) · Paintings: diffusion models
// Fonts: Alfa Slab One, Lora (SIL OFL 1.1) · Needs postext ≥ 1.85.1
//
// The menu of a bakery, a folded card of brown kraft. Kraft takes no white from the paper, so
// the name and the course heads print in an opaque white ink, and the paintings sit on white
// mounts that the same ink lays under them; the menu text is a dark brown in process colour.
import {
  buildDocumentWithFonts, renderPageToCanvas, registerResourceImage, preflightDocument,
} 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 = 'white-ink-kraft-menu';

// ─── 1 · Design ─────────────────────────────────────────────────────────────
// #region answer: kraft as the paper, and an opaque white as a spot ink
// The paper is a colour that prints no ink: the screen and Folio paint kraft, and no plate
// gets a dot of it. Because it is not white, the preflight knows the white ink shows on it.
// The white is a spot ink with the white finish: its own plate, laid down before the others.
const kraft = { hex: '#c19a6b', model: 'cmyk', cmyk: { c: 0, m: 0, y: 0, k: 0 } };
const WHITE = { name: 'Opaque White', cmyk: { c: 0, m: 0, y: 0, k: 0 } };
// A white ink overprints by default: laid under the colours, it must not cut holes in them.
const white = { hex: '#f7f4ee', model: 'spot', spot: { ...WHITE, finish: { kind: 'white' } } };
const PRINT = { standard: 'pdfx4', outputProfile: 'fogra52', convertImages: false,
  inks: [{ name: 'Opaque White', aliases: ['White'], finish: { kind: 'white' } }] };

// White type on a green panel must knock the green out.
// White printed under the green is hidden by it. For white type on a colour, the type must cut
// its shape out of the colour, so this white says overprint: false. Its hex differs by one
// step from the other white, since the PDF tells colours apart by hex; both print on one plate.
const whiteOut = { hex: '#f6f3ed', model: 'spot',
  spot: { ...WHITE, finish: { kind: 'white' }, overprint: false } };
// #endregion

const palette = {
  kraft, white, whiteOut,
  // The brown overprints: on the white card it lands on the white instead of cutting it away.
  ink: { hex: '#3b2a1c', model: 'cmyk', cmyk: { c: 0, m: 45, y: 75, k: 82 }, overprint: true },
  green: { hex: '#2f5a43', model: 'cmyk', cmyk: { c: 80, m: 25, y: 75, k: 40 } }, // the panel
};
const col = (id) => ({ ...palette[id], paletteId: id });
const colorPalette = [...Object.entries(palette).map(([id, value]) => ({ id, name: id, value })),
  { id: 'main-color', name: 'ink (defaults)', value: palette.ink }];

const [TRIM_W, TRIM_H] = [148, 210]; // A5, an A4 card folded once

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

变化

#笔记本封面

把菜单换成封面上的一个标题和一组白色线条图案:纸张、油墨和油墨表都保持不变。

#印两遍白

在深色牛皮纸上,印刷厂可以印两遍白,让白色更白。在订单里注明即可;文件不变,仍然只有一块白版。

常见问题

  • 白墨落在纸张为白色或未设置的页面上,印出来什么也看不见。把page.backgroundColor设成所用的纸,用CMYK全0定义,印前检查就不再警告。
  • 直接印在牛皮纸上、下面没有白色的图片,所有浅色部分都会透出棕色。凡是要保住原色的图片,都在下面放一个白色方框,就像这里的衬板一样。
  • 彩色上的白字不能叠印。按默认设置,它会印在彩色下面,然后消失不见。

致谢

文本
原创文字, CC BY 4.0
图片
  • A sourdough loaf, on the cover · Generated With Diffusion Models · 原创
  • Three pastries · Generated With Diffusion Models · 原创
  • A cup of coffee · Generated With Diffusion Models · 原创
字体
Alfa Slab One (SIL OFL 1.1) · Lora (SIL OFL 1.1)
沙盒PDF