// printExport.js // Einbinden: // Aufruf: window.printCV(element, cvTitle, cvSettings, template) window.printCV = async function (el, cvTitle, cvSettings, template) { // ── 1. Lokale CSS-Datei direkt fetchen (kein CORS-Problem) ────── let globalCss = ''; try { globalCss = await fetch('/styles/global.css').then(r => r.text()); } catch (e) { console.warn('global.css nicht geladen', e); } // ── 2. Inline ${el.innerHTML} `; // ── 6. Blob-URL statt document.write ──────────────────────────── const blob = new Blob([html], { type: 'text/html; charset=utf-8' }); const blobUrl = URL.createObjectURL(blob); const win = window.open(blobUrl, '_blank', 'width=900,height=1200'); if (!win) { alert('Popup wurde blockiert. Bitte Popup-Blocker deaktivieren.'); URL.revokeObjectURL(blobUrl); return; } win.addEventListener('load', () => { // Blob-URL freigeben sobald geladen URL.revokeObjectURL(blobUrl); // Fonts + base64-PNGs (Icons) etwas Zeit geben setTimeout(() => { win.focus(); win.print(); win.addEventListener('afterprint', () => win.close()); }, 1000); }); };