`;
for (const category in appData) {
if (category === 'Dashboard') continue;
html += `
${category}
`;
for (const key in appData[category]) {
const item = appData[category][key];
const value = parseFloat(item.value).toLocaleString('en-US', {maximumFractionDigits: 2});
html += `
| ${item.label} |
${item.prefix || ''}${value} |
`;
}
html += '
';
}
pdfContainer.innerHTML = html;
document.body.appendChild(pdfContainer);
html2canvas(pdfContainer, { scale: 2 }).then(canvas => {
const imgData = canvas.toDataURL('image/png');
const { width, height } = pdf.internal.pageSize;
const imgHeight = canvas.height * width / canvas.width;
let heightLeft = imgHeight, position = 0;
pdf.addImage(imgData, 'PNG', 0, 0, width, imgHeight);
heightLeft -= height;
while (heightLeft > 0) {
position = heightLeft - imgHeight;
pdf.addPage();
pdf.addImage(imgData, 'PNG', 0, position, width, imgHeight);
heightLeft -= height;
}
pdf.save('land-subdivision-profit-analysis.pdf');
document.body.removeChild(pdfContainer);
});
}
initialize();
});