Interactive Investment Risk Profiling Quiz
Risk Level: ${profile}
This profile is based on your responses regarding age, investment goals, horizon, and risk tolerance.
`; document.getElementById('riskResult').innerHTML = output; } window.downloadProfilePDF = function () { const resultElement = document.getElementById('riskResult'); const button = document.getElementById('downloadPDF'); if (!resultElement.innerHTML.trim()) { alert("Please generate your risk profile before downloading the PDF."); return; } button.style.display = 'none'; html2canvas(resultElement).then(canvas => { const imgData = canvas.toDataURL('image/png'); const { jsPDF } = window.jspdf; const pdf = new jsPDF(); const pdfWidth = pdf.internal.pageSize.getWidth(); const pdfHeight = (canvas.height * pdfWidth) / canvas.width; pdf.addImage(imgData, 'PNG', 0, 10, pdfWidth, pdfHeight); pdf.save("Investment_Risk_Profile.pdf"); button.style.display = 'inline-block'; }); } });