White Paper Summary Generator

White Paper Summary Generator

Distill lengthy documents into concise summaries instantly.

${p}

`).join(''); }; const generateSummaryHandler = () => { const text = whitepaperText.value; if (!text.trim()) { alert("Please paste the white paper text before generating a summary."); switchTab('input'); return; } const summaryHtml = summarizeText(text); summaryOutput.innerHTML = summaryHtml; pdfBtn.disabled = false; switchTab('summary'); }; const generatePDF = () => { if (!generatedSummary) return; const { jsPDF } = window.jspdf; const doc = new jsPDF(); const pageHeight = doc.internal.pageSize.height; const pageWidth = doc.internal.pageSize.width; const margin = 20; const maxLineWidth = pageWidth - margin * 2; let y = margin; // Header doc.setFont('times', 'bold'); doc.setFontSize(24); doc.setTextColor(15, 23, 42); // Slate 900 doc.text('White Paper Summary', pageWidth / 2, y, { align: 'center' }); y += 15; // Sub-header doc.setFont('times', 'normal'); doc.setFontSize(12); doc.setTextColor(71, 85, 105); // Slate 500 doc.text('This document provides a condensed summary of the key points from the source material.', pageWidth / 2, y, { align: 'center'}); y += 15; // Line separator doc.setDrawColor(203, 213, 225); // Slate 300 doc.setLineWidth(0.5); doc.line(margin, y, pageWidth - margin, y); y += 15; // Body text doc.setFont('times', 'normal'); doc.setFontSize(12); doc.setTextColor(30, 41, 59); // Slate 700 doc.setLineHeightFactor(1.5); const lines = doc.splitTextToSize(generatedSummary, maxLineWidth); doc.text(lines, margin, y); // Footer const footerY = pageHeight - 15; doc.line(margin, footerY, pageWidth - margin, footerY); doc.setFontSize(9); doc.setTextColor(148, 163, 184); // Slate 400 const today = new Date().toLocaleDateString('en-US'); doc.text(`Summary Generated on ${today}`, margin, footerY + 5); doc.save('White_Paper_Summary.pdf'); }; const switchTab = (tabName) => { if (!tabs.includes(tabName)) return; currentTab = tabName; Object.values(tabContent).forEach(content => content.classList.add('hidden')); tabContent[tabName].classList.remove('hidden'); Object.values(tabButtons).forEach(button => button.classList.remove('active')); tabButtons[tabName].classList.add('active'); updateNavButtons(); }; const updateNavButtons = () => { const currentIndex = tabs.indexOf(currentTab); prevBtn.disabled = currentIndex === 0; nextBtn.disabled = currentIndex === tabs.length - 1; }; const navigateTabs = (direction) => { const currentIndex = tabs.indexOf(currentTab); let newIndex = direction === 'next' ? Math.min(currentIndex + 1, tabs.length - 1) : Math.max(currentIndex - 1, 0); switchTab(tabs[newIndex]); }; generateBtn.addEventListener('click', generateSummaryHandler); pdfBtn.addEventListener('click', generatePDF); window.app = { switchTab, navigateTabs, }; updateNavButtons(); });
Scroll to Top