Business Research Report Creator

Business Research Report Creator

Structure your professional business insights, section by section.

${data.company}

Market Analysis

${data.market}

Competitive Landscape

${data.competition}

Products & Services

${data.products}

Marketing & Sales Strategy

${data.strategy}

Financial Projections

${data.financials}

`; }; const getReportData = () => { const data = {}; tabIds.forEach(id => { if (id !== 'review') { const element = document.getElementById(`report-${id}`); data[id] = element ? element.value.trim() : `No ${id} provided.`; if (!data[id]) { data[id] = `No content provided for this section.`; } } }); return data; }; tabs.forEach(tab => { tab.addEventListener('click', () => { currentTabIndex = tabIds.indexOf(tab.dataset.tab); updateTabs(); }); }); prevButton.addEventListener('click', () => { if (currentTabIndex > 0) { currentTabIndex--; updateTabs(); } }); nextButton.addEventListener('click', () => { if (currentTabIndex < tabIds.length - 1) { currentTabIndex++; updateTabs(); } }); downloadPdfButton.addEventListener('click', () => { downloadPdfButton.textContent = 'Generating...'; downloadPdfButton.disabled = true; try { generateBusinessPdf(getReportData()); } catch(e) { console.error("PDF Generation Failed:", e); alert("An error occurred while generating the PDF."); } finally { downloadPdfButton.textContent = 'Download Report as PDF'; downloadPdfButton.disabled = false; } }); const generateBusinessPdf = (data) => { const { jsPDF } = window.jspdf; const doc = new jsPDF({ orientation: 'p', unit: 'mm', format: 'a4' }); const pageWidth = doc.internal.pageSize.getWidth(); const pageHeight = doc.internal.pageSize.getHeight(); const margin = 20; const contentWidth = pageWidth - (margin * 2); let y = 0; const addSection = (title, text) => { const titleHeight = 10; const minSectionHeight = 25; // Minimum space to start a section const textLines = doc.splitTextToSize(text, contentWidth); const textHeight = textLines.length * 5 + 5; // 5mm per line approx if (y + titleHeight + textHeight > pageHeight - margin) { doc.addPage(); y = margin; addHeaderFooter(); } y += 10; doc.setFont('helvetica', 'bold'); doc.setFontSize(14); doc.setTextColor('#0f766e'); // teal-700 doc.text(title, margin, y); y += 2; doc.setDrawColor('#5eead4'); // teal-300 doc.line(margin, y, margin + 40, y); y += 8; doc.setFont('helvetica', 'normal'); doc.setFontSize(11); doc.setTextColor('#374151'); // gray-700 doc.text(textLines, margin, y); y += textHeight; }; const addHeaderFooter = () => { const pageCount = doc.internal.getNumberOfPages(); for(let i = 1; i <= pageCount; i++) { doc.setPage(i); // Header doc.setFontSize(9); doc.setTextColor('#9ca3af'); // gray-400 doc.text('Business Research Report', margin, 10); // Footer const today = new Date().toLocaleDateString('en-US'); doc.text(`Generated: ${today} | Page ${i} of ${pageCount}`, pageWidth - margin, pageHeight - 10, { align: 'right' }); } }; // --- Title Page --- doc.setFillColor('#f0fdfa'); // teal-50 doc.rect(0, 0, pageWidth, pageHeight, 'F'); doc.setFont('helvetica', 'bold'); doc.setFontSize(26); doc.setTextColor('#134e4a'); // teal-900 doc.text('Business Research Report', pageWidth / 2, pageHeight / 2 - 20, { align: 'center' }); doc.setFontSize(14); doc.setTextColor('#115e59'); // teal-800 doc.text('Confidential', pageWidth / 2, pageHeight / 2 - 10, { align: 'center' }); // --- Content Pages --- doc.addPage(); y = margin; addSection("Executive Summary", data.summary); addSection("Company Description", data.company); addSection("Market Analysis", data.market); addSection("Competitive Landscape", data.competition); addSection("Products & Services", data.products); addSection("Marketing & Sales Strategy", data.strategy); addSection("Financial Projections", data.financials); addHeaderFooter(); doc.save('Business-Research-Report.pdf'); }; updateTabs(); });
Scroll to Top