Writing Tone Analyzer

Writing Tone Analyzer

Analyze your text to understand its underlying emotional and stylistic tones.

Enter Your Text

Tone Analysis

Your analysis results will appear here.

${message}

`; elements.resultsPlaceholder.classList.remove('hidden'); elements.resultsContainer.classList.add('hidden'); } // --- PDF Generation --- function generatePdf() { if (!analysisResults || !originalText) return; const { jsPDF } = window.jspdf; const doc = new jsPDF(); doc.setFont('helvetica', 'bold'); doc.setFontSize(18); doc.text("Writing Tone Analysis Report", doc.internal.pageSize.getWidth() / 2, 20, { align: 'center' }); doc.setFontSize(11); doc.setTextColor(100); doc.text(`Generated on: ${new Date().toLocaleDateString('en-US')}`, 14, 30); doc.setFont('helvetica', 'bold'); doc.setFontSize(12); doc.text("Original Text", 14, 45); doc.setFont('helvetica', 'normal'); doc.setFontSize(10); const textLines = doc.splitTextToSize(originalText, doc.internal.pageSize.getWidth() - 28); doc.text(textLines, 14, 52); let lastY = 52 + (textLines.length * 5); doc.setFont('helvetica', 'bold'); doc.setFontSize(12); doc.text("Tone Summary", 14, lastY + 10); doc.setFont('helvetica', 'normal'); doc.setFontSize(10); const summaryLines = doc.splitTextToSize(analysisResults.summary, doc.internal.pageSize.getWidth() - 28); doc.text(summaryLines, 14, lastY + 17); lastY += 17 + (summaryLines.length * 5); const tableBody = analysisResults.tones.map(t => [ t.tone, (t.score * 100).toFixed(0) + '%' ]); doc.autoTable({ startY: lastY + 5, head: [['Detected Tone', 'Confidence Score']], body: tableBody, theme: 'striped', headStyles: { fillColor: '#0f172a' } }); doc.save(`tone-analysis-report.pdf`); } initialize(); });
Scroll to Top