`;
};
pdfRenderContainer.innerHTML = buildPdfReportHtml(organizedNotesData);
html2canvas(pdfRenderContainer, { scale: 2, useCORS: true })
.then(canvas => {
const imgData = canvas.toDataURL('image/png');
const pdf = new jsPDF({ orientation: 'portrait', unit: 'px', format: 'a4' });
const pdfWidth = pdf.internal.pageSize.getWidth();
const canvasWidth = canvas.width;
const canvasHeight = canvas.height;
const ratio = canvasWidth / canvasHeight;
const widthInPdf = pdfWidth;
const heightInPdf = widthInPdf / ratio;
pdf.addImage(imgData, 'PNG', 0, 0, widthInPdf, heightInPdf);
pdf.save(`Notes_${organizedNotesData.title.replace(/\s+/g, '_')}.pdf`);
});
};
// --- Event Listeners ---
inputTabBtn.addEventListener('click', () => switchToTab('input'));
viewTabBtn.addEventListener('click', () => switchToTab('view'));
downloadPdfBtn.addEventListener('click', generatePdf);
});