`;
html += `
`; html += `
`; html += `
This profile is based solely on the user's subjective assessment of the listed factors. It is a simplified tool for structuring personal research and understanding potential risk areas. It does NOT represent an objective financial or credit analysis, nor is it investment advice. High-yield bonds carry significant risks. Always conduct thorough due diligence from multiple credible sources and consider consulting a qualified financial advisor.
`; pdfContentElement.innerHTML = html; document.body.appendChild(pdfContentElement); html2canvas(pdfContentElement, { scale: 1.5, useCORS: true, windowWidth: pdfContentElement.scrollWidth, windowHeight: pdfContentElement.scrollHeight }).then(canvas => { const imgData = canvas.toDataURL('image/png'); const pdfWidth = pdf.internal.pageSize.getWidth(); const pageHeight = pdf.internal.pageSize.getHeight(); const imgActualWidth = canvas.width; const imgActualHeight = canvas.height; const aspectRatio = imgActualWidth / imgActualHeight; const pageMargin = 10; let imgWidthInPdf = pdfWidth - (2 * pageMargin); let imgHeightInPdf = imgWidthInPdf / aspectRatio; let heightLeft = imgHeightInPdf; let currentYPosition = pageMargin; if (imgHeightInPdf > pageHeight - (2 * pageMargin)) { imgHeightInPdf = pageHeight - (2 * pageMargin); imgWidthInPdf = imgHeightInPdf * aspectRatio; } const xOffset = (pdfWidth - imgWidthInPdf) / 2; pdf.addImage(imgData, 'PNG', xOffset, currentYPosition, imgWidthInPdf, imgHeightInPdf); heightLeft -= (pageHeight - (2 * pageMargin)); let pageCount = 1; while (heightLeft > 0 && pageCount < 20) { // Limit pages for safety currentYPosition = heightLeft - imgHeightInPdf; // Source Y is negative for next slice pdf.addPage(); pdf.addImage(imgData, 'PNG', xOffset, currentYPosition, imgWidthInPdf, imgHeightInPdf); heightLeft -= (pageHeight - (2 * pageMargin)); pageCount++; } pdf.save(`${data.bondName.replace(/[^a-zA-Z0-9]/g, '_') || 'HighYieldBond'}_RiskProfile.pdf`); document.body.removeChild(pdfContentElement); }).catch(error => { console.error("Error generating High-Yield Bond Risk PDF:", error); alert("Could not generate PDF. See console for details."); if (document.body.contains(pdfContentElement)) { document.body.removeChild(pdfContentElement); } }); }