# ERNE protocol DOCX/PDF formatting lessons

Use when creating or revising ERNE AG Holzbau meeting/protocol documents, especially when a user supplies an ERNE Marketing header/footer DOCX and CD Manual.

## Corporate design basics observed

- Office documents use **Arial**.
- ERNE primary blue: `#365294`.
- ERNE beige: `#E2D3C4`; light beige table striping is acceptable for readability.
- Use full-width, clean tables with blue header rows and alternating light rows.
- Keep the ERNE header/footer template intact when supplied; work from the user's optimized DOCX if they provide one.

## Protocol formatting defaults that worked

- Top margin / header spacing: leave generous breathing room; in the final iteration, ~`2.35 cm` top margin and ~`0.85 cm` header distance avoided the title sitting too close to the header.
- Bottom margin / footer spacing: keep roughly `1.85 cm` bottom margin and `0.85 cm` footer distance.
- Title sizes:
  - `PROTOKOLL`: 11 pt
  - main protocol title, e.g. `1. FACHPLANER-JOUR-FIXE`: 16 pt
  - major section headings: 13 pt
  - table header/title rows: 10 pt
  - normal body text and table body: 8.5 pt
- Add more vertical spacing between Traktanden than between bullets inside a Traktandum.
- Keep each Traktandum together as a block where possible: set `keep_together` and `keep_with_next` on heading + bullets; if space is tight, prefer moving the whole Traktandum to the next page.
- Avoid a page break inside important tables such as `Risiken und Chancen`: start that section/table on a new page if needed.
- Pendenzenliste: avoid tiny font. If the table is too wide, remove only low-value columns (e.g. `Prio`) before shrinking below 8.5 pt. Keep `Relevanz` when requested. Permit line wraps inside table cells rather than compressing text.
- Keep all tables the same content width/full page width for a calmer layout.

## PDF generation and verification

- Generate the PDF from the final DOCX using LibreOffice headless (`libreoffice --headless --convert-to pdf ...`) so the PDF reflects the same layout as the DOCX.
- Do not trust programmatic export alone. Render at least:
  - page 1 for header/title spacing and metadata table,
  - the `Risiken und Chancen` / `Pendenzenliste` pages,
  - the final page for footer and orphan rows.
- Use visual inspection to catch: table splits, too-small fonts, clipped rows, footer collisions, and title/header crowding.

## Implementation hints with python-docx

- Set section margins/header/footer distances explicitly.
- Harmonize run fonts across paragraphs and table cells (`Arial`, prescribed sizes).
- Use `w:cantSplit` on table rows to avoid row splitting.
- Set table width to full page with `w:tblW type="pct" w="5000"`; keep `table.autofit = True` for wrapping.
- For page-break-sensitive sections, set `paragraph_format.page_break_before = True` on the heading rather than letting a table split awkwardly.
