SPB Git forge
3commits 1branches 0releases
2.9 MBsize
maindefault branch
1 h agolast push
HTML 57.2% Shell 19.1% Python 11.2% CSS 7.4% JavaScript 5.1%
1.7 KB · 25 lines javascript
Raw Blame History
1// Rendu PDF du dossier : cover.html (pleine page, sans en-tête) + body.html (en-tête / pied avec pagination).2// Lancer depuis un dossier où Playwright est installé (ex. ~/Desktop/uqo-eval) : node <chemin>/print.mjs3import { chromium } from "playwright";4import path from "node:path";5import { fileURLToPath } from "node:url";6const here = path.dirname(fileURLToPath(import.meta.url));7const b = await chromium.launch();8const p = await b.newPage();910await p.goto("file://" + path.join(here, "cover.html"), { waitUntil: "networkidle" });11await p.pdf({ path: path.join(here, "cover.pdf"), width: "297mm", height: "210mm", printBackground: true, margin: { top: 0, right: 0, bottom: 0, left: 0 }, preferCSSPageSize: false });1213await p.goto("file://" + path.join(here, "body.html"), { waitUntil: "networkidle" });14await p.waitForTimeout(500);15const font = "font-family:-apple-system,BlinkMacSystemFont,'SF Pro Text',Helvetica,Arial,sans-serif;font-size:7.4pt;color:#868b99;";16await p.pdf({17  path: path.join(here, "body.pdf"), format: "A4", landscape: true, printBackground: true, preferCSSPageSize: false,18  margin: { top: "13mm", right: "14mm", bottom: "15mm", left: "14mm" },19  displayHeaderFooter: true,20  headerTemplate: `<div style="${font}width:100%;padding:0 14mm;display:flex;justify-content:space-between;margin-top:4mm"><span style="font-weight:600;color:#0f1115">MacLustr</span><span>Dossier technique · inventaire complet</span></div>`,21  footerTemplate: `<div style="${font}width:100%;padding:0 14mm;display:flex;justify-content:space-between;margin-bottom:5mm"><span>www.maclustr.io · contact@spboucher.ai</span><span>page <span class="pageNumber"></span> / <span class="totalPages"></span></span></div>`,22});23await b.close();24console.log("cover.pdf + body.pdf OK");25