export const printHtmlContent = (html: string, title = 'Letter') => {
    const printWindow = window.open('', '_blank', 'width=900,height=700');

    if (!printWindow) return;

    printWindow.document.open();
    printWindow.document.write(`
    <html>
      <head>
        <title>${title}</title>
        <style>
          body {
            font-family: Arial, sans-serif;
            padding: 24px;
            line-height: 1.6;
            color: #000;
          }

          p {
            margin-bottom: 12px;
          }

          @media print {
            body {
              padding: 0;
            }
          }
        </style>
      </head>
      <body>
        ${html}
      </body>
    </html>
  `);

    printWindow.document.close();

    // wait for DOM render
    printWindow.focus();

    setTimeout(() => {
        printWindow.print();
        printWindow.close();
    }, 300);
};
