`;
}
});
summaryHTML += `
`;
}
});
summaryHTML += `
`;
summaryContainer.innerHTML = summaryHTML;
const pdfButton = document.getElementById('download-pdf-button');
if (pdfButton) {
pdfButton.addEventListener('click', downloadPDF);
}
}
// --- PDF GENERATION ---
function downloadPDF() {
const { jsPDF } = window.jspdf;
const doc = new jsPDF({ orientation: 'p', unit: 'mm', format: 'a4' });
const pageMargin = 20;
const pageWidth = doc.internal.pageSize.getWidth();
const contentWidth = pageWidth - (pageMargin * 2);
let y;
function addSlide(title, data, isFirstPage = false) {
if (!isFirstPage) doc.addPage();
y = pageMargin;
doc.setFont('helvetica', 'bold');
doc.setFontSize(18);
doc.setTextColor('#1f2937'); // Dark Gray
doc.text(title, pageWidth / 2, y, { align: 'center' });
y += 8;
doc.setLineWidth(0.5);
doc.setDrawColor('#d1d5db'); // Light Gray
doc.line(pageMargin, y, pageWidth - pageMargin, y);
y += 15;
doc.setFont('helvetica', 'normal');
doc.setFontSize(11);
doc.setTextColor('#374151');
if (typeof data === 'string') {
const lines = doc.splitTextToSize(data, contentWidth);
doc.text(lines, pageMargin, y);
} else if (Array.isArray(data)) {
data.forEach(item => {
doc.setFont('helvetica', 'bold');
doc.text(item.label, pageMargin, y);
doc.setFont('helvetica', 'normal');
const lines = doc.splitTextToSize(item.value, contentWidth - 20); // Indent value
doc.text(lines, pageMargin + 5, y + 6);
const textHeight = lines.length * 5; // Approx height
y += textHeight + 8;
});
}
}
// Title Slide
const companyName = deckData.company?.companyName || 'My Company';
const tagline = deckData.company?.tagline || 'Tagline';
doc.setFont('helvetica', 'bold');
doc.setFontSize(32);
doc.text(companyName, pageWidth / 2, 130, { align: 'center' });
doc.setFont('helvetica', 'normal');
doc.setFontSize(16);
doc.setTextColor('#6b7280');
doc.text(tagline, pageWidth / 2, 145, { align: 'center' });
// Content Slides
addSlide('The Problem', deckData.problem?.problemStatement || 'N/A');
addSlide('Our Solution', deckData.solution?.solutionStatement || 'N/A');
addSlide('Market Size', [
{label: 'TAM:', value: deckData.market?.tam || 'N/A'},
{label: 'SAM:', value: deckData.market?.sam || 'N/A'},
{label: 'SOM:', value: deckData.market?.som || 'N/A'},
]);
addSlide('Business Model', deckData.businessModel?.monetization || 'N/A');
addSlide('The Team', deckData.team?.teamMembers || 'N/A');
addSlide('The Ask', [
{label: 'Funding Amount:', value: deckData.ask?.fundingAmount || 'N/A'},
{label: 'Use of Funds:', value: deckData.ask?.fundAllocation || 'N/A'},
]);
// Page numbers
const pageCount = doc.internal.getNumberOfPages();
for(let i = 1; i <= pageCount; i++) {
doc.setPage(i);
doc.setFontSize(9);
doc.setTextColor('#9ca3af');
doc.text(`Page ${i}`, pageWidth - pageMargin, 287, { align: 'right' });
}
doc.save(`${companyName.replace(/\s+/g, '_')}_Pitch_Deck.pdf`);
}
// --- EVENT LISTENERS ---
nextButton.addEventListener('click', () => {
if (currentTabIndex < TABS_CONFIG.length - 1) {
goToTab(currentTabIndex + 1);
}
});
prevButton.addEventListener('click', () => {
if (currentTabIndex > 0) {
goToTab(currentTabIndex - 1);
}
});
initialize();
});