Family Office Investment Strategy Planner
Define Your Core Objectives
Select Key Strategies & Actions
Review Your Strategy Summary
Your personalized investment strategy summary will appear here. Please complete the previous sections and click "Generate Summary" or navigate to this tab.
No strategic pillars selected.
'; } summaryHTML += 'Selected Actionable Steps:
'; if (actionableSteps.length > 0) { summaryHTML += '- ';
actionableSteps.forEach(step => summaryHTML += `
- ${step} `); summaryHTML += '
No actionable steps selected.
'; } if (customNotes) { summaryHTML += `Other Custom Strategies or Action Notes:
${customNotes.replace(/\n/g, '
')}
Other Custom Strategies or Action Notes:
None provided.
'; } summaryOutputDiv.innerHTML = summaryHTML; } if (generateSummaryBtn) { generateSummaryBtn.addEventListener('click', generateSummary); } // --- PDF Download --- function loadJsPdfIfNeeded(callback) { if (jsPdfLoaded) { if (callback) callback(); return; } const script = document.createElement('script'); script.src = 'https://cdnjs.cloudflare.com/ajax/libs/jspdf/2.5.1/jspdf.umd.min.js'; script.onload = () => { jsPdfLoaded = true; console.log("jsPDF loaded dynamically."); if (callback) callback(); }; script.onerror = () => { console.error("Failed to load jsPDF dynamically. PDF functionality will be unavailable."); alert("Error: Could not load PDF generation library. Please ensure your internet connection is active or contact support."); }; document.head.appendChild(script); } function downloadAsPdf() { if (!jsPdfLoaded) { alert("PDF library is not yet loaded. Please wait a moment or try again. If the issue persists, ensure jsPDF is included on the page."); return; } // Ensure summary is fresh generateSummary(); const { jsPDF } = window.jspdf; const doc = new jsPDF({ unit: 'pt', format: 'a4' }); // Using points for better control const pageMargin = 40; const pageWidth = doc.internal.pageSize.getWidth() - 2 * pageMargin; let y = pageMargin; // Title doc.setFontSize(18); doc.setFont(undefined, 'bold'); doc.setTextColor(44, 62, 80); // --tool-primary-color const mainTitleText = plannerContainer.querySelector('.foisp-main-title') ? plannerContainer.querySelector('.foisp-main-title').innerText : "Family Office Investment Strategy"; doc.text(mainTitleText, pageMargin, y); y += 30; // Helper to add text and manage y position function addText(text, size, style, color, indent = 0) { if (y > doc.internal.pageSize.getHeight() - pageMargin - 20) { // Check for page end doc.addPage(); y = pageMargin; } doc.setFontSize(size); doc.setFont(undefined, style); doc.setTextColor(color[0], color[1], color[2]); const splitText = doc.splitTextToSize(text, pageWidth - indent); doc.text(splitText, pageMargin + indent, y); y += (doc.getTextDimensions(splitText).h) + (size * 0.5); // Line height based on font size } function addSectionTitle(title) { y += 10; // Space before section title addText(title, 14, 'bold', [44, 62, 80]); // --tool-primary-color y += 5; } // Core Objectives addSectionTitle("Core Objectives"); const objectivesData = [ { title: "Wealth Preservation:", value: getElementValue('foispObjectivePreservation') }, { title: "Sustainable Wealth Growth:", value: getElementValue('foispObjectiveGrowth') }, { title: "Legacy & Values Alignment:", value: getElementValue('foispObjectiveLegacy') }, { title: "Liquidity Management:", value: getElementValue('foispObjectiveLiquidity') } ]; objectivesData.forEach(obj => { addText(obj.title, 11, 'bold', [51, 51, 51]); addText(obj.value || "Not specified", 10, 'normal', [85, 85, 85], 10); y += 5; }); // Strategic Pillars const strategicPillars = getCheckedValues('foispStrategicPillar'); addSectionTitle("Selected Strategic Pillars"); if (strategicPillars.length > 0) { strategicPillars.forEach(pillar => { addText(`• ${pillar}`, 10, 'normal', [51, 51, 51], 10); }); } else { addText("No strategic pillars selected.", 10, 'italic', [120, 120, 120], 10); } y += 5; // Actionable Steps const actionableSteps = getCheckedValues('foispActionableStep'); addSectionTitle("Selected Actionable Steps"); if (actionableSteps.length > 0) { actionableSteps.forEach(step => { addText(`• ${step}`, 10, 'normal', [51, 51, 51], 10); }); } else { addText("No actionable steps selected.", 10, 'italic', [120, 120, 120], 10); } y += 5; // Custom Notes const customNotes = getElementValue('foispCustomNotes'); addSectionTitle("Other Custom Strategies or Action Notes"); if (customNotes) { addText(customNotes, 10, 'normal', [51, 51, 51], 10); } else { addText("None provided.", 10, 'italic', [120, 120, 120], 10); } // Footer for PDF const pageCount = doc.internal.getNumberOfPages(); for (let i = 1; i <= pageCount; i++) { doc.setPage(i); doc.setFontSize(8); doc.setTextColor(150); doc.text(`Page ${i} of ${pageCount} - Family Office Investment Strategy Planner`, pageMargin, doc.internal.pageSize.getHeight() - (pageMargin / 2)); doc.text(new Date().toLocaleDateString(), doc.internal.pageSize.getWidth() - pageMargin - doc.getTextWidth(new Date().toLocaleDateString()), doc.internal.pageSize.getHeight() - (pageMargin / 2)); } doc.save('Family_Office_Investment_Strategy.pdf'); } if (downloadPdfBtn) { downloadPdfBtn.addEventListener('click', () => { loadJsPdfIfNeeded(downloadAsPdf); }); } else { console.warn("Download PDF button not found. PDF functionality will be unavailable."); } // --- Initialization --- showTab(0); // Show the first tab initially loadJsPdfIfNeeded(); // Attempt to load jsPDF on page load if not already present });