Technical Specification Document Generator

Technical Specification Document Generator

Outline the technical details of your project with clarity.

None specified.

'; document.getElementById('generated-spec-content').innerHTML = html; }; // --- PDF Generation --- downloadPdfBtn.addEventListener('click', () => { const { jsPDF } = window.jspdf; const doc = new jsPDF({ orientation: 'portrait', unit: 'mm', format: 'a4' }); const data = getSpecData(); const pageW = doc.internal.pageSize.getWidth(); const margin = 15; let y = 0; const primaryColor = '#4338ca'; // Indigo-700 const textColor = '#374151'; // Gray-700 const addFooter = () => { const pageCount = doc.internal.getNumberOfPages(); for (let i = 1; i <= pageCount; i++) { doc.setPage(i); doc.setFontSize(9); doc.setTextColor('#6b7280'); // Gray-500 doc.text(`Page ${i} of ${pageCount}`, pageW - margin, doc.internal.pageSize.getHeight() - 10, { align: 'right' }); doc.text(data.projectName, margin, doc.internal.pageSize.getHeight() - 10); } }; // Title Page doc.setFontSize(28).setFont(undefined, 'bold').setTextColor(primaryColor).text(data.projectName, pageW / 2, 100, { align: 'center' }); doc.setFontSize(18).setFont(undefined, 'normal').text('Technical Specification Document', pageW / 2, 115, { align: 'center' }); const date = new Date('2025-09-15T00:00:00').toLocaleDateString('en-US', { year: 'numeric', month: 'long', day: 'numeric' }); doc.setFontSize(12).setTextColor(textColor).text(`Date: ${date}`, pageW / 2, 135, { align: 'center' }); // Content Pages doc.addPage(); y = margin + 10; const addSection = (title, content, isList = false) => { if (y > 250) { doc.addPage(); y = margin + 10; } doc.setFontSize(16).setFont(undefined, 'bold').setTextColor(primaryColor).text(title, margin, y); y += 8; doc.setFontSize(10).setFont(undefined, 'normal').setTextColor(textColor); if (isList) { content.forEach(item => { if (y > 270) { doc.addPage(); y = margin + 10; } doc.text(`• ${item}`, margin + 5, y); y += 5; }); } else { const lines = doc.splitTextToSize(content || 'Not provided.', pageW - margin * 2); doc.text(lines, margin, y); y += (lines.length * 4); } y += 8; }; addSection('1. Project Summary', data.projectSummary); addSection('2. Architecture Overview', data.architectureOverview); addSection('3. Technology Stack', data.techStack); addSection('4. Functional Requirements', data.functionalReqs, true); addSection('5. Non-Functional Requirements', data.nonFunctionalReqs); addSection('6. Data Model', data.dataModel); if (data.apiEndpoints.length > 0) { if (y > 220) { doc.addPage(); y = margin + 10; } doc.setFontSize(16).setFont(undefined, 'bold').setTextColor(primaryColor).text('7. API Endpoints', margin, y); y += 8; doc.autoTable({ head: [['Method', 'Path', 'Description']], body: data.apiEndpoints.map(e => [e.method, e.path, e.desc]), startY: y, theme: 'grid', headStyles: { fillColor: primaryColor }, }); } addFooter(); doc.save(`${data.projectName.replace(/\s+/g, '-')}-Tech-Spec.pdf`); }); // Initialize addFunctionalRequirement(); addApiEndpoint(); updateTabUI(0); lucide.createIcons(); });
Scroll to Top