/* Render docs/launch/one-pager.html to an A4 PDF. * * node docs/launch/build-one-pager.cjs [output.pdf] * * It asserts the result is a single page, because a one-pager that quietly becomes two is worse * than useless — the second sheet is where the contact details end up, and nobody prints it. */ const { chromium } = require('playwright'); const path = require('path'); const SRC = path.join(__dirname, 'one-pager.html'); const OUT = process.argv[2] || path.join(process.env.HOME || '.', 'Downloads', 'ThreadCount-one-pager.pdf'); const A4_PX = Math.round((297 / 25.4) * 96); // A4 height at CSS 96dpi (async () => { const b = await chromium.launch(); const p = await b.newPage(); await p.goto('file://' + SRC, { waitUntil: 'networkidle' }); await p.evaluate(() => document.fonts.ready); await p.waitForTimeout(800); // let the webfont settle before measuring const h = await p.evaluate(() => document.body.getBoundingClientRect().height); await p.pdf({ path: OUT, format: 'A4', printBackground: true, margin: { top: 0, right: 0, bottom: 0, left: 0 } }); await b.close(); console.log(`content ${Math.round(h)}px against an A4 page of ${A4_PX}px`); if (h > A4_PX + 1) { console.error('SPILLS ONTO A SECOND PAGE — trim the content or the block spacing, not the type size.'); process.exit(1); } console.log('one page ->', OUT); })();