Inflation Hedge Portfolio Planner Inflation Hedge Portfolio Planner Plan a portfolio to protect your purchasing power. Planning Inputs Current Portfolio Size ($) Target Annual Inflation (%) Investment Horizon (Years) Create Plan Your portfolio plan will appear here. Generating Plan... Portfolio Forecast Download Report Projected Value- Inflation Impact- Real Value (Today's $s)- Suggested Allocation Portfolio Growth AI Strategic Commentary Suggested Allocation Portfolio Growth AI Strategic Commentary ${formatCurrency(projectedValue)} Inflation Impact${formatCurrency(inflationImpact)} Real Value${formatCurrency(realValue)}`; document.getElementById('pdf-allocation-chart-img').src = allocationChart ? allocationChart.toBase64Image() : ''; document.getElementById('pdf-growth-chart-img').src = growthChart ? growthChart.toBase64Image() : ''; document.getElementById('pdf-commentary').textContent = commentary; const contentToPrint = document.getElementById('pdf-output'); contentToPrint.style.display = 'block'; try { const canvas = await html2canvas(contentToPrint, { scale: 2 }); const { jsPDF } = window.jspdf; const imgData = canvas.toDataURL('image/png'); const pdf = new jsPDF({ orientation: 'portrait', unit: 'pt', format: 'a4' }); const pdfWidth = pdf.internal.pageSize.getWidth(); const pdfHeight = (canvas.height * pdfWidth) / canvas.width; pdf.addImage(imgData, 'PNG', 0, 0, pdfWidth, pdfHeight); pdf.save(`Inflation-Hedge-Plan.pdf`); } catch (err) { console.error("Error generating PDF:", err); alert("Could not generate PDF."); } finally { contentToPrint.style.display = 'none'; } } // --- EVENT LISTENERS --- planBtn.addEventListener('click', handlePlanning); downloadPdfBtn.addEventListener('click', handlePdfDownload); // --- INITIALIZATION --- lucide.createIcons(); });