Actionable Recommendations
${recommendationsHTML}Compliance Report
For: ${companyName}
${reportContent} `; downloadPdfBtn.textContent = 'Generating...'; downloadPdfBtn.disabled = true; container.classList.remove('hidden'); container.style.position = 'absolute'; container.style.left = '-9999px'; container.style.top = '0'; try { const canvas = await html2canvas(pdfPreview, { scale: 2 }); const imgData = canvas.toDataURL('image/png'); const pdf = new jsPDF({ orientation: 'p', unit: 'pt', format: 'a4' }); const pdfWidth = pdf.internal.pageSize.getWidth(); const margin = 40; const usableWidth = pdfWidth - margin * 2; const imgScaledHeight = (canvas.height * usableWidth) / canvas.width; pdf.addImage(imgData, 'PNG', margin, margin, usableWidth, imgScaledHeight); pdf.save(`${companyName.replace(/ /g, '_')}_Compliance_Report.pdf`); } catch (error) { console.error("Error generating PDF:", error); } finally { container.classList.add('hidden'); container.style.position = ''; downloadPdfBtn.textContent = 'Download PDF Report'; downloadPdfBtn.disabled = false; pdfPreview.innerHTML = ''; } } downloadPdfBtn.addEventListener('click', downloadPDF); // --- Initial Load --- updateNavButtons(); });