Investment Risk Detector

Investment Risk Detector

Analyze potential investments to identify common risks and red flags.

${data ? data.explanation : 'This investment type is considered to have high inherent volatility and potential for loss.'}

`; }); } else { factorsHtml += `

No specific keyword-based risk factors were detected. Standard market risks still apply.

`; } document.getElementById('pdf-detected-risks').innerHTML = factorsHtml; try { // 2. Render the populated template to a canvas const canvas = await html2canvas(document.getElementById('pdf-content'), { scale: 2, useCORS: true }); const imgData = canvas.toDataURL('image/png'); // 3. Create PDF const pdf = new jsPDF({ orientation: 'portrait', unit: 'pt', format: 'a4' }); const pdfWidth = pdf.internal.pageSize.getWidth(); const imgProps = pdf.getImageProperties(imgData); const pdfHeight = (imgProps.height * pdfWidth) / imgProps.width; pdf.addImage(imgData, 'PNG', 0, 0, pdfWidth, pdfHeight); pdf.save('Investment_Risk_Report.pdf'); } catch (error) { console.error("Failed to generate PDF:", error); alert("An error occurred while generating the PDF."); } } // --- Event Listeners --- tabs.forEach((tab, index) => tab.btn.addEventListener('click', () => switchTab(index))); prevBtn.addEventListener('click', () => switchTab(currentTab - 1)); nextBtn.addEventListener('click', () => switchTab(currentTab + 1)); detectRiskBtn.addEventListener('click', detectRisk); downloadPdfBtn.addEventListener('click', handlePdfDownload); // --- Initialization --- updateNavButtons(); });
Scroll to Top