'use client'; interface PrintCardButtonProps { imageUrls: string[]; className?: string; } // Prints the card images at their physical size, one per page, from a hidden iframe export default function PrintCardButton({ imageUrls, className }: PrintCardButtonProps) { const handlePrint = () => { const iframe = document.createElement('iframe'); iframe.setAttribute('aria-hidden', 'true'); iframe.style.cssText = 'position:fixed;right:0;bottom:0;width:0;height:0;border:0;visibility:hidden'; iframe.srcdoc = `${imageUrls .map((url) => ``) .join('')}`; iframe.onload = async () => { const printWindow = iframe.contentWindow; if (!printWindow) return; await Promise.all( Array.from(printWindow.document.images).map((img) => img.decode().catch(() => undefined)) ); printWindow.addEventListener('afterprint', () => iframe.remove()); printWindow.focus(); printWindow.print(); }; document.body.appendChild(iframe); }; return ( ); }