nas-runbooks/common/html-to-png-puppeteer.md

21 lines
1.0 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# HTML vers PNG : rendu headless Puppeteer / Chromium
**Date** : 2026-06-21, révisé 09/07/2026 (retrait de l'approche Gotenberg — container désinstallé)
**Contexte** : html2canvas échoue dans les iframes sandbox (Claude.ai, widgets). Polices Google Fonts et SVG complexes bloqués par CORS.
**Solution** : rendu serveur avec Chromium headless via Puppeteer (bash_tool Claude).
## Pièges critiques
- Entry point : lib/puppeteer/puppeteer.js (pas lib/esm/)
- page.waitForTimeout() supprimé en v25+ → setTimeout natif
- --no-sandbox obligatoire dans container Claude
- networkidle0 + attente 2 s = polices externes chargées
## Cas validé (2026-06-21)
Carte félicitations Bac 2026 — HTML/SVG 680×680 px + Google Fonts → PNG 1360×1360 px (137 Ko), upload Facebook direct.
**Règle absolue** : html2canvas = NON en iframe sandbox. Puppeteer = OUI.
**Note** : l'ancienne « Approche 2 » via Gotenberg (HTML→PDF→PNG) n'existe plus — gotenberg a été désinstallé le 21/06/2026 (cf. cleanup-stack-documentaire.md).