`;
});
}
exportHTML += `
`;
pdfExportContainer.innerHTML = exportHTML;
html2canvas(document.getElementById('pdfExportContent'), { scale: 2, useCORS: true }).then(canvas => {
const imgData = canvas.toDataURL('image/png');
const pdf = new jsPDF({ orientation: 'p', unit: 'mm', format: 'a4' });
const pdfWidth = pdf.internal.pageSize.getWidth();
const canvasWidth = canvas.width;
const canvasHeight = canvas.height;
const ratio = canvasWidth / canvasHeight;
const imgWidth = pdfWidth - 20; // with margin
const imgHeight = imgWidth / ratio;
let heightLeft = imgHeight;
let position = 10;
pdf.addImage(imgData, 'PNG', 10, position, imgWidth, imgHeight);
heightLeft -= (pdf.internal.pageSize.getHeight() - 20);
while (heightLeft > 0) {
position -= (pdf.internal.pageSize.getHeight() - 20);
pdf.addPage();
pdf.addImage(imgData, 'PNG', 10, position, imgWidth, imgHeight);
heightLeft -= (pdf.internal.pageSize.getHeight() - 20);
}
pdf.save('legal_research_memo.pdf');
pdfExportContainer.innerHTML = ''; // Clean up
});
});
// --- INITIALIZE APP ---
renderResearchLog();
switchTab(0);
document.getElementById('dateFound').valueAsDate = new Date();
});
