// diag-pdf.jsx — Hoja PDF clara, una página, todos los elementos visibles al imprimir. function PdfSheet({ data, scores, rec, growth }) { const L = window.diagLevelLabel; const p = rec.program; const today = window.diagFmtDate(new Date()); const progHref = 'index.html#programas'; const first = data.nombre ? data.nombre.split(' ')[0] : 'Tu perfil'; return (
); } function PdfButton({ nombre }) { const go = () => { const prev = document.title; document.title = 'Diagnóstico 360' + (nombre ? ' - ' + nombre : ''); const sheet = document.getElementById('pdfSheet'); let applied = false; if (sheet) { // Force the whole sheet onto ONE A4 page: measure natural height and // scale down uniformly if it would overflow (A4 @96dpi ≈ 1123px tall). const A4 = 1123; const natural = sheet.scrollHeight; const scale = natural > A4 ? (A4 / natural) : 1; sheet.style.setProperty('--pdf-scale', scale); sheet.classList.add('pdf-printing'); applied = true; } const cleanup = () => { if (sheet && applied) { sheet.classList.remove('pdf-printing'); sheet.style.removeProperty('--pdf-scale'); } document.title = prev; }; // give layout a tick to settle before printing setTimeout(() => { window.print(); setTimeout(cleanup, 400); }, 60); }; React.useEffect(() => { window.__diagPrintPdf = go; }, [nombre]); return ( ); } Object.assign(window, { PdfSheet, PdfButton });