Brand Storytelling Generator Brand Storytelling Generator Weave the narrative that defines your brand. 1. Origin 2. Mission 3. Values 4. Voice 5. Story What is your brand's name? The "Aha!" Moment Your Purpose Your Audience Core Values Brand Voice Download Brand Story as PDF Previous Next Generate Story ${body.replace(/\n/g, '')}`; currentTab = tabs.length - 1; showTab(currentTab); }; const downloadPDF = () => { if (!generatedStory.headline) return; const { jsPDF } = window.jspdf; const doc = new jsPDF({ unit: 'pt', format: 'a4' }); const filename = `${generatedStory.brandName.replace(/\s+/g, '-')}-Brand-Story.pdf`; const pageHeight = doc.internal.pageSize.height; const pageWidth = doc.internal.pageSize.width; const margin = 80; const contentWidth = pageWidth - margin * 2; let cursorY = 0; // --- PDF Template: Brand Story Guide --- doc.addFont('times', 'normal', 'WinAnsiEncoding'); doc.addFont('helvetica', 'bold', 'WinAnsiEncoding'); // Header cursorY = margin; doc.setFont('helvetica', 'bold'); doc.setFontSize(28); doc.setTextColor('#333333'); doc.text("Brand Story Guide", pageWidth / 2, cursorY, { align: 'center' }); cursorY += 35; doc.setFontSize(18); doc.setTextColor('#A0522D'); doc.text(generatedStory.brandName, pageWidth / 2, cursorY, { align: 'center' }); cursorY += 40; // Helper function const addSection = (title, content) => { if (!content) return; doc.setFont('helvetica', 'bold'); doc.setFontSize(12); doc.setTextColor('#333333'); const titleLines = doc.splitTextToSize(title.toUpperCase(), contentWidth); doc.text(titleLines, margin, cursorY); cursorY += titleLines.length * 12 + 4; doc.setDrawColor('#EAEAEA'); doc.setLineWidth(0.5); doc.line(margin, cursorY, margin + 80, cursorY); cursorY += 20; doc.setFont('times', 'normal'); doc.setFontSize(12); doc.setTextColor('#444444'); const contentLines = doc.splitTextToSize(content, contentWidth); if (cursorY + (contentLines.length * 14) > pageHeight - margin) { doc.addPage(); cursorY = margin; } doc.text(contentLines, margin, cursorY); cursorY += contentLines.length * 14 + 30; }; // Add content sections addSection("Our Origin", generatedStory.origin); addSection("Our Mission", generatedStory.mission); addSection("Our Audience", generatedStory.audience); addSection("Our Values", generatedStory.values); addSection("Our Voice", generatedStory.voice); // Footer const pageCount = doc.internal.getNumberOfPages(); for (let i = 1; i <= pageCount; i++) { doc.setPage(i); doc.setFontSize(9); doc.setTextColor('#AAAAAA'); doc.text(`Page ${i} of ${pageCount}`, pageWidth / 2, pageHeight - 30, { align: 'center'}); } doc.save(filename); }; // --- Event Handling --- nextButton.addEventListener('click', () => { if (currentTab < tabs.length - 2) { currentTab++; showTab(currentTab); } }); prevButton.addEventListener('click', () => { if (currentTab > 0) { currentTab--; showTab(currentTab); } }); generateButton.addEventListener('click', generateStory); downloadPdfButton.addEventListener('click', downloadPDF); tabs.forEach(tab => { tab.addEventListener('click', () => { const tabIndex = parseInt(tab.dataset.tab, 10); if (tabIndex === tabs.length - 1 && !generatedStory.headline) { generateStory(); } else { currentTab = tabIndex; showTab(currentTab); } }); }); // --- Initialization --- showTab(0); });