本文へスキップ
レシピ番号58

レシピ集 · 第1章 · ページとグリッド

DIN 5008に従うビジネスレター

A4で2ページのドイツ語の見積書です。件名をH1にし、そのデザインでレターヘッド、宛名、情報ブロックを書式Bの位置に固定します。

このページの内容
出力
Canvas · PDF
レベル
中級
Postext
Postext 1.65.0で検証済み
1.34.0以上が必要 · postext-pdf ≥ 1.34.0
ライセンス
2026年10月16日更新
コードMIT · 本文CC BY 4.0

1ページ(全2ページ)

  • 英語の見本:日本語版はまだありません
  • 仕上がり210 × 297 mm
  • 1段
  • Nunito Sans 10.5/15
  • Familjen Grotesk
  • Reddit Mono
  • 2ページ
  • レベル
  • Postext 1.57.1
  • 組版時間71 ms
  • コード180行

かんたんな説明

ドイツの窓工房が出す2ページの見積書です。窓付き封筒に収まるよう、宛名などビジネスレターの各部をドイツの規格が定める位置に置く方法を示します。

できあがり

ベルリンで二重窓を修復する架空の工房Fensterwerkstatt Tessinが、集合住宅の管理会社に見積書を送ります。ドイツ語でA4判2枚、DIN 5008の書式Bに従って組みます。上部を横切るベルリンブルーの帯に工房のロゴと名前が入ります。その下では、各部分が規格の定める位置に収まります。差出人行と宛名はDL封筒の窓から見える85 × 45 mmの欄の中に、情報ブロックは左端から125 mmの位置に、太字の件名は欄の2行下の空きのあとに置き、折り目マークとパンチマークは105 mm、148.5 mm、210 mmに付けます。会社情報は両方の用紙の地に3段で入ります。2枚目は「Seite 2 von 2」の横に整理番号をくり返し、コードで描いた署名で終わります。

このレシピが答える質問

  • バッジやステッカーをページ上の決まった位置に固定するには?
  • すべてのページに透かし、背景の色、装飾画像を加えるには?
  • 章扉や白ページで柱を隠したり、空白の偶数ページを部の色で塗ったりするには?
  • エピグラフ、献辞、署名、大きな引用符の付いたプルクオートを組むには?

手短な答え

script.js · 59〜78行コード全体で見る
const at = (x, y, size) => ({ anchor: { to: 'page', edge: 'top-left' }, // mm from the corner
  offset: { x: mm(x), y: mm(y) }, ...(size && { size }) });
const ZONE = DIN.field.y + DIN.notes; // 62.7 mm: where the six address lines start
const SUBJECT = DIN.field.y + DIN.field.h + 2 * LEAD * PT; // two blank lines under the field
const firstPage = () => ({ enabled: true, slot: { elements: [ // in paint order
  ...letterhead(), // band, logo and name, and the corners of the window
  text('from', FROM, FACE.from, at(DIN.left, ZONE - 3.6)), // the return line, underlined
  rule('from-rule', 'muted', { anchor: { to: '#from', edge: 'below' }, offset: { y: mm(0.6) },
    size: { width: mm(WINDOW) } }),
  // One attribute holds the whole address: each '\n' in it starts a new line.
  text('to', '{attr.to}', FACE.address, at(DIN.left, ZONE, { width: mm(WINDOW) })),
  ...infoBlock(), // labels, and values from {attr.*}
  text('subject', '{titleText}', FACE.subject, at(DIN.left, SUBJECT, { width: mm(TEXT) })),
] } });
// The H1 reserves the sheet down to its lowest element (gotcha: opener-reserves-anchored).
// fontFamily: the design paints the H1, but the build measures it (default: Open Sans).
const headings = () => ({ fontFamily: 'Familjen Grotesk', levels: [{ level: 1,
  breakBefore: { enabled: true, parity: 'any' }, // a letter starts on the next sheet
  marginBottom: pt(2 * LEAD), // two blank lines between the subject and the salutation
  advancedDesign: firstPage() }] });

材料

種類
Nunito Sans, Familjen Grotesk, Reddit Mono (SIL OFL 1.1)
素材
なし:画像はすべてコードで描画

作り方

#1 · 1ページ目をミリ単位で用紙に固定する

script.js · 59〜78行コード全体で見る
const at = (x, y, size) => ({ anchor: { to: 'page', edge: 'top-left' }, // mm from the corner
  offset: { x: mm(x), y: mm(y) }, ...(size && { size }) });
const ZONE = DIN.field.y + DIN.notes; // 62.7 mm: where the six address lines start
const SUBJECT = DIN.field.y + DIN.field.h + 2 * LEAD * PT; // two blank lines under the field
const firstPage = () => ({ enabled: true, slot: { elements: [ // in paint order
  ...letterhead(), // band, logo and name, and the corners of the window
  text('from', FROM, FACE.from, at(DIN.left, ZONE - 3.6)), // the return line, underlined
  rule('from-rule', 'muted', { anchor: { to: '#from', edge: 'below' }, offset: { y: mm(0.6) },
    size: { width: mm(WINDOW) } }),
  // One attribute holds the whole address: each '\n' in it starts a new line.
  text('to', '{attr.to}', FACE.address, at(DIN.left, ZONE, { width: mm(WINDOW) })),
  ...infoBlock(), // labels, and values from {attr.*}
  text('subject', '{titleText}', FACE.subject, at(DIN.left, SUBJECT, { width: mm(TEXT) })),
] } });
// The H1 reserves the sheet down to its lowest element (gotcha: opener-reserves-anchored).
// fontFamily: the design paints the H1, but the build measures it (default: Open Sans).
const headings = () => ({ fontFamily: 'Familjen Grotesk', levels: [{ level: 1,
  breakBefore: { enabled: true, parity: 'any' }, // a letter starts on the next sheet
  marginBottom: pt(2 * LEAD), // two blank lines between the subject and the salutation
  advancedDesign: firstPage() }] });

at()は要素の左上の角を'page'、つまり仕上がり枠に固定します(要素の配置)。そのためxとyはどれも用紙の角からの距離になり、規格の数値をそのまま書けます。宛名は横25 mm、縦62.7 mm、情報ブロックの最初のラベルは125と50です。これらの要素がH1のデザインになります。見出しのテキストは件名({titleText})で、その属性に宛名と整理番号を入れます。こうして設定が便箋を、Markdownが手紙の中身を受け持ちます。100.6 mmにある件名がいちばん下の要素なので、見出しは件名の下端までの用紙を確保します。marginBottomで2行のアキを加え、あいさつ文は次のグリッド行、117 mmから始まります。

宛名は1つの属性で、行のあいだに\nを入れます。デザインのテキストでは、\nごとに行が改まります。見出しは本文の段の中にありますが、各要素をページに固定しているので、帯もロゴも名前も27 mmの天の余白より上にそのまま描かれます。

#2 · 固定した1つのラベルから情報ブロックをつなげる

script.js · 82〜93行コード全体で見る
const INFO = [['Ihr Zeichen', 'ihr-zeichen'], ['Ihre Nachricht vom', 'ihre-nachricht'],
  ['Unser Zeichen', 'unser-zeichen'], ['Name', 'name'], ['Telefon', 'telefon'],
  ['E-Mail', 'email'], ['Datum', 'datum']]; // [label, heading attribute]
const VALUE = 29; // mm from the labels to the values
const infoBlock = () => INFO.flatMap(([label, key], i) => [
  text(`label-${i}`, label, FACE.label, i === 0 ? at(DIN.info.x, DIN.info.y) : {
    anchor: { to: `#label-${i - 1}`, edge: 'below' }, // each label under the last
    offset: { y: mm(key === 'datum' ? ROW * PT : 0) } }), // a blank row before the date
  text(`value-${i}`, `{attr.${key}}`, FACE.value, { // a 12 pt row as well, on the label's baseline
    anchor: { to: `#label-${i}`, edge: 'align-top' }, offset: { x: mm(VALUE) },
    size: { width: mm(DIN.info.w - VALUE) } }),
]);

用紙に固定するのは最初のラベルだけです。ほかのラベルはどれも直前のラベルの'below'に、各値は自分のラベルに'align-top'と29 mmのオフセットで固定するので、INFOに行を足しても座標は要りません。デザインのテキストはベースラインを行ボックスの80%の位置に置きます。7 ptのラベルも9 ptの値もlineHeight: pt(ROW)で12 ptの行になるので、4.23 mmごとのどの行でも同じベースラインに並びます。

#3 · レターヘッドを同じデザインに描く

script.js · 97〜118行コード全体で見る
const [BAND, TICK] = [32, 3]; // mm: the band's depth, each arm of the window's corner angles
const LOGO = { y: 7, h: 18 }; // mm: the mark, centred in the band
const CRAFTS = 3 * 7.5 * 1.45 * PT; // mm: three 7.5 pt lines at 1.45
const letterhead = () => [
  { kind: 'box', id: 'band', style: { backgroundColor: col('brand') },
    placement: at(0, 0, { width: 'fill', height: mm(BAND) }) },
  { kind: 'image', id: 'logo', resourceId: 'logo',
    placement: at(DIN.left, LOGO.y, { height: mm(LOGO.h) }) },
  text('name', 'Tessin', face('Familjen Grotesk', 30, 700, 'paper', { lineHeight: 1 }),
    { anchor: { to: '#logo', edge: 'right-of' }, offset: { x: mm(5), y: mm(1.2) } }),
  text('trade', 'FENSTERWERKSTATT · BERLIN', face('Reddit Mono', 7.5, 500, 'sky',
    { letterSpacing: pt(1.2) }), { anchor: { to: '#name', edge: 'below' },
    offset: { x: mm(0.4), y: mm(1.5) } }),
  text('crafts', 'Kastenfenster\nHolzfenster\nDenkmalpflege', face('Reddit Mono', 7.5,
    400, 'sky', { lineHeight: 1.45, align: 'right' }),
    at(210 - DIN.right - 45, LOGO.y + (LOGO.h - CRAFTS) / 2, { width: mm(45) })),
  ...[[0, 0], [1, 0], [0, 1], [1, 1]].flatMap(([right, low], i) => { // turned inwards
    const [x, y] = [DIN.field.x + right * DIN.field.w, DIN.field.y + low * DIN.field.h];
    return [rule(`across-${i}`, 'marks', at(x - right * TICK, y, { width: mm(TICK) })),
      rule(`down-${i}`, 'marks', at(x, y - low * TICK, { height: mm(TICK) }), 'vertical')];
  }),
];

帯は用紙の角に固定した囲みです。width: 'fill'で端から端まで伸ばし、32 mmの深さで27 mmの天の余白を5 mm越えます。ロゴは画像要素で、高さ18 mmでリソースを描き、幅は図から取ります(画像要素)。名前はロゴの'right-of'に、業種の行は名前の'below'に固定します。3 mmの罫8本で、85 × 45 mmの宛名欄、つまり封筒の窓から見える部分の四隅に角マークを描きます。

#4 · どの用紙にも共通するものはヘッダーとフッターに置く

script.js · 122〜144行コード全体で見る
const header = { elements: [
  // In the H1's design they would stretch its reserve (gotcha: opener-reserves-anchored).
  ...[[DIN.folds[0], 5], [DIN.punch, 8], [DIN.folds[1], 5]].map(([y, length], i) =>
    rule(`mark-${i}`, 'marks', at(0, y, { width: mm(length) }))), // fold, punch, fold
  // Page 1 opens with the H1, which makes it an 'opener'; later sheets are 'body' pages.
  { kind: 'box', id: 'strip', pages: 'body', style: { backgroundColor: col('brand') },
    placement: at(0, 0, { width: 'fill', height: mm(4) }) },
  text('ref', 'Fensterwerkstatt Tessin · Unser Zeichen {attr.unser-zeichen} · {attr.datum}',
    FACE.small, at(DIN.left, 13.2), { pages: 'body' }),
  text('page', 'Seite {pageNumber} von {totalPages}', FACE.small,
    at(210 - DIN.right - 40, 13.2, { width: mm(40) }), { pages: 'body', align: 'right' }),
] };
const FOOT = 297 - DIN.bottom + 5; // mm: the hairline over the company data
const COMPANY = [ // three columns, 57 mm apart, inside the bottom margin
  'Fensterwerkstatt Tessin GmbH\nRennbahnstraße 48\n13086 Berlin\nTelefon 030 23125-400',
  'Geschäftsführer Martin Tessin\nAmtsgericht Charlottenburg\nHRB 000000 B\nUSt-IdNr. DE000000000',
  'Musterbank Berlin\nIBAN DE00 0000 0000 0000 0000 00\nBIC MUSTDEBBXXX',
];
const footer = { elements: [
  rule('foot-rule', 'rule', at(DIN.left, FOOT, { width: mm(TEXT) })),
  ...COMPANY.map((lines, i) => text(`company-${i}`, lines, FACE.small,
    at(DIN.left + 57 * i, FOOT + 2.5, { width: mm(52) }))),
] };

H1のデザインのうち件名の下に固定した要素は、見出しが確保する高さを増やします。210 mmの折り目マークをデザインに入れると、あいさつ文は222.8 mmまで下がり、手紙は3ページになります。ヘッダー枠はすべてのページに描かれ、領域を確保しないので、3つのマークはそこに置きます(ヘッダーとフッター)。1ページ目はH1で始まるので'opener'ページになり、pages: 'body'で青い帯、整理番号の行、Seite {pageNumber} von {totalPages}を2枚目以降に限定します。整理番号の行は{attr.unser-zeichen}と{attr.datum}でH1の属性を参照します。

#5 · 署名を本文の流れに置く

script.js · 148〜157行コード全体で見る
const resourceTypes = [{ id: 'drawing', name: 'Zeichnung', shortLabel: 'Zeichnung',
  numberingTemplate: '{n}', resetOn: 'never', counterFormat: 'decimal', captionPrefix: '' }];
const drawing = (id, width, height, altText, placement) => ({ id, typeId: 'drawing',
  kind: 'svg', svg: { fileId: `${id}.svg`, width, height }, altText, placement,
  createdAt: 0, updatedAt: 0 });
const resources = [ // an image element draws the logo; nothing cites it
  drawing('logo', 200, 280, 'Zeichen der Fensterwerkstatt Tessin, ein Kastenfenster'),
  drawing('signature', 760, 328, 'Unterschrift von Martin Tessin',
    { position: 'here', width: 0.297 }), // 49 × 21.1 mm: under 4 lines, no grid gap below
];

::resource{id="signature"}で「Mit freundlichen Grüßen」の下に図を置き、width: 0.297で幅49 mm、深さ21.1 mmにします。15 ptの行4本にわずかに足りない深さです。本文の流れの中でリソースに続くテキストは、本文のグリッドに戻ります。0.25では図の深さが17.8 mmで、その下にグリッドが加えた3.4 mmのために氏名が署名から離れていました。このリソース種別はcaptionPrefixが空で、Postextは接頭辞とキャプションがどちらも空ならキャプションを組まないため、署名の下にはラベルも番号も出ません(リソースの種類)。ロゴも同じ種別のリソースで、画像要素だけが描きます。:refも::resourceもそれを指定しないので、本文の流れには入りません。

レシピの全体

Sandbox
// ═══ Postext Cookbook · Nº 058 · Business letter to DIN 5008 ═════════════════════
// https://postext.dev/en/cookbook/din-business-letter
// Code: MIT · Text: original, in German (CC BY 4.0) · Logo, signature: drawn in code (CC BY 4.0)
// Fonts: Nunito Sans, Familjen Grotesk, Reddit Mono (SIL OFL 1.1) · Needs postext ≥ 1.34.0
// A German quotation on A4 whose H1 design pins the letterhead and the address to DIN 5008.
import {
  buildDocumentWithFonts, renderPageToCanvas, registerResourceImage,
} from 'https://esm.sh/postext';
import { renderToPdf, decompressWoff2 } from 'https://esm.sh/postext-pdf';

const LANG = 'en'; // @lang: the language of the sample document ('en' | 'es')
const RECIPE = 'din-business-letter';

// ─── 1 · Design ─────────────────────────────────────────────────────────────
const palette = {
  ink: '#1f2429', brand: '#1b4a73', // text, a blue-grey near-black; Berlin blue, for the band
  sky: '#b4cbe0', paper: '#ffffff', // the trade and the crafts on the band; the logo and name
  muted: '#5b6670', pen: '#26408f', // labels, return line, company data; the signature's ink
  marks: '#98a3ad', rule: '#c9d1d8', // fold marks, window corners; the hairline in the footer
};
// col(id): a colour linked to its palette entry, with the entry's hex beside the id.
const col = (id) => ({ hex: palette[id], model: 'hex', paletteId: id });
// main-color is the engine's default accent: the dashes of the list take it.
const colorPalette = Object.entries({ ...palette, 'main-color': palette.brand })
  .map(([id, hex]) => ({ id, name: id, value: { hex, model: 'hex' } }));

// DIN 5008, form B: every position in mm from the sheet's top-left corner.
const DIN = {
  left: 25, right: 20, top: 27, bottom: 30, // the margins of the text
  field: { x: 20, y: 45, w: 85, h: 45 }, // the address field, behind the envelope window
  notes: 17.7, // the field's top zone, for the return line; the address zone takes the rest
  info: { x: 125, y: 50, w: 75 }, // the information block
  folds: [105, 210], punch: 148.5, // fold marks for a DL envelope, and the punch mark
};
const TEXT = 210 - DIN.left - DIN.right; // 165 mm of text width
const WINDOW = DIN.field.w - 2 * (DIN.left - DIN.field.x); // 75 mm: text inset 5 mm each side
const PT = 25.4 / 72; // mm per point
const [LEAD, ROW] = [15, 12]; // pt: the body's leading, a row of the information block

// Design text is centred by default, and a header or footer line ends in '…': left, wrapped.
const text = (id, content, face, placement, more) => ({ kind: 'text', id, content,
  align: 'left', overflow: 'wrap', ...face, placement, ...more }); // more: pages, align
const rule = (id, colour, placement, direction = 'horizontal') => ({ kind: 'rule', id,
  direction, thickness: pt(0.5), color: col(colour), placement });
const face = (fontFamily, size, fontWeight, colour, more) => ({ fontFamily, fontSize: pt(size),
  fontWeight, color: col(colour), ...more });
const FACE = { // lineHeight: a dimension is the line's depth, a number multiplies the size
  label: face('Reddit Mono', 7, 400, 'muted', { lineHeight: pt(ROW) }),

組み立てたscript.jsはそのまま動きます。任意のページのモジュールスクリプトに貼り付けるか、レシピをCodePenで開いてください。 GitHub上のレシピのフォルダー ↗ (新しいタブで開きます)

よくあるつまずき

つまずき

章扉はページに固定した要素のうち最も下のものまで高さを確保する

詳細デザインの章扉は、最も下にある要素までの高さを確保します。見出しより下にあるページや裁ち落としに固定した要素もこれに含まれるため、ページの下端に置いた装飾があると本文が次のページへ押し出されます。こうした要素にはreserve: falseを与えてください(postext 1.5から)。固定した位置に描かれ、高さは何も確保しません。帯そのものに従う要素(帯の下端に固定したものや、高さが'fill'のもの)が帯の高さを決めることはありません。 デザインした章扉 →

つまずき

ヘッダーとフッターの要素は本文の上に描かれる

ヘッダーとフッターの要素はページの上に重ねて描かれ、本文の領域はそのための場所を空けません。要素は余白の中に収めてください。その場所を確保するのは余白です。 柱とノンブル →

  • {totalPages}は文書全体のページを数えるので、1つのMarkdownファイルに手紙を2通入れると、1通目の2枚目は「Seite 2 von 4」になります。手紙は1通ずつ組んでください。

クレジット

レシピ
Ignacio Ferro
本文
書き下ろしの文章, CC BY 4.0
フォント
Nunito Sans (SIL OFL 1.1) · Familjen Grotesk (SIL OFL 1.1) · Reddit Mono (SIL OFL 1.1)
SandboxPDF