Filter Your Results

`); doc.close();iframe.contentWindow.focus();// FIX 4: Preload all background images before printing const allStyles = Array.from(doc.querySelectorAll('style')); const imageUrls = []; allStyles.forEach(s => { const matches = s.innerHTML.matchAll(/url\("([^"]+)"\)/g); for (const match of matches) imageUrls.push(match[1]); });const imagePromises = imageUrls.map(url => { return new Promise(resolve => { const img = new iframe.contentWindow.Image(); img.onload = resolve; img.onerror = resolve; // don't block on failed images img.src = url; }); });// Print only after all images are loaded Promise.all(imagePromises).then(() => { iframe.contentWindow.print(); setTimeout(() => iframe.remove(), 1000); });});