`;
};
// --- PDF DOWNLOAD ---
window.downloadPDF = () => {
if (typeof jspdf === 'undefined' || typeof html2canvas === 'undefined') {
console.error("PDF generation error: jsPDF or html2canvas library not loaded.");
alert("Could not generate PDF. A required library is missing.");
return;
}
const { jsPDF } = window.jspdf;
const agreementDiv = document.getElementById('agreement-output');
if (!agreementDiv) {
console.error("Agreement content element not found.");
return;
}
const pdf = new jsPDF('p', 'pt', 'a4');
const source = agreementDiv;
const margin = 40;
pdf.html(source, {
callback: function(doc) {
doc.save("Loan-Agreement.pdf");
},
x: margin,
y: margin,
width: 595 - (margin * 2), // A4 width in points is 595
windowWidth: source.scrollWidth
});
};
// --- INITIALIZE UI ---
updateTabs();
});
