3. Risk Assessment
Likely Consequences:
${reportData.riskConsequences}
Assessed Risk Level: ${reportData.riskLevel}
4. Notifications Made
Supervisory Authority Notified: ${reportData.authorityNotified} on ${reportData.authorityDate}
Data Subjects Notified: ${reportData.subjectsNotified} on ${reportData.subjectsDate}
5. Containment & Mitigation
Containment Steps Taken:
${reportData.containmentSteps}
Mitigation Steps Taken:
${reportData.mitigationSteps}
Report Generated: ${new Date().toLocaleString('en-US')}
`; }; ui.downloadPdfBtn.addEventListener('click', async () => { if (!window.jspdf || !window.html2canvas) { alert('PDF generation library not loaded.'); return; } ui.loader.classList.remove('hidden'); ui.downloadPdfBtn.disabled = true; try { const { jsPDF } = window.jspdf; const canvas = await html2canvas(ui.reportPreview, { scale: 2 }); const pdf = new jsPDF('p', 'mm', 'a4'); const pdfWidth = pdf.internal.pageSize.getWidth(); const margin = 15; const contentWidth = pdfWidth - margin * 2; const imgHeight = canvas.height * contentWidth / canvas.width; let heightLeft = imgHeight; let position = 0; pdf.addImage(canvas.toDataURL('image/png'), 'PNG', margin, margin, contentWidth, imgHeight); heightLeft -= (pdf.internal.pageSize.getHeight() - margin * 2); while (heightLeft > 0) { position = heightLeft - imgHeight + margin; pdf.addPage(); pdf.addImage(canvas.toDataURL('image/png'), 'PNG', margin, position, contentWidth, imgHeight); heightLeft -= (pdf.internal.pageSize.getHeight() - margin * 2); } pdf.save('GDPR_Data_Breach_Report.pdf'); } catch (error) { console.error("PDF Generation Error:", error); alert("An error occurred generating the PDF."); } finally { ui.loader.classList.add('hidden'); ui.downloadPdfBtn.disabled = false; } }); window.changeTab = (tabIndex) => { currentTab = tabIndex; updateTabUI(); }; ui.prevBtn.addEventListener('click', () => { if (currentTab > 0) { currentTab--; updateTabUI(); } }); ui.nextBtn.addEventListener('click', () => { if (currentTab < ui.tabs.length - 1) { currentTab++; updateTabUI(); } }); ui.riskLevel.addEventListener('change', updateNotificationGuidance); updateTabUI(); });