Sentence Rephraser
Refine your writing by discovering new ways to express yourself.
Enter Your Text
Rephrased Options
Preview & Export Report
Your rephrased sentences will appear here.
No rephrased options generated yet.
'; } previewBodyEl.innerHTML = html; }; const handleDownloadPdf = () => { if (!window.jspdf) { console.error('jsPDF not loaded.'); return; } const { jsPDF } = window.jspdf; const pdf = new jsPDF({ orientation: 'portrait', unit: 'pt', format: 'a4' }); const pageW = pdf.internal.pageSize.getWidth(); const margin = 50; let cursorY = 0; // --- PDF Template: Rephrasing Report --- pdf.setFillColor(237, 242, 247); // Gray bg pdf.rect(0, 0, pageW, 70, 'F'); pdf.setFont('helvetica', 'bold').setFontSize(20).setTextColor(45, 55, 72); // Dark Gray pdf.text('Sentence Rephrasing Report', margin, 45); cursorY = 110; // Original Sentence pdf.setFont('helvetica', 'bold').setFontSize(11).setTextColor(42, 108, 176); // Darker blue pdf.text('ORIGINAL SENTENCE', margin, cursorY); cursorY += 5; pdf.setDrawColor(226, 232, 240).line(margin, cursorY, pageW - margin, cursorY); // Gray line cursorY += 20; const originalLines = pdf.setFont('helvetica', 'normal').setFontSize(12).setTextColor(74, 85, 104) // Medium Gray .splitTextToSize(originalSentenceEl.value || 'N/A', pageW - margin * 2); pdf.text(originalLines, margin, cursorY); cursorY += (originalLines.length * 12) + 25; // Rephrased Options pdf.setFont('helvetica', 'bold').setFontSize(11).setTextColor(42, 108, 176); // Darker blue pdf.text(`REPHRASED OPTIONS (TONE: ${toneEl.value.toUpperCase()})`, margin, cursorY); cursorY += 5; pdf.setDrawColor(226, 232, 240).line(margin, cursorY, pageW - margin, cursorY); // Gray line cursorY += 20; const generatedLines = (generatedOptionsEl.value || "No options generated.").split('\n'); for (const line of generatedLines) { if (line.trim().startsWith('* ')) { if (cursorY > pdf.internal.pageSize.getHeight() - margin) { pdf.addPage(); cursorY = margin; } const cleanLine = line.substring(line.indexOf('* ') + 2).trim(); const bulletLines = pdf.setFont('helvetica', 'normal').setFontSize(11).setTextColor(45, 55, 72) .splitTextToSize(cleanLine, pageW - margin * 2 - 15); pdf.text('•', margin, cursorY); pdf.text(bulletLines, margin + 15, cursorY); cursorY += (bulletLines.length * 11) + 10; } } pdf.save(`Sentence-Rephraser-Report.pdf`); }; // --- Event Listeners --- if (generateBtn) generateBtn.addEventListener('click', handleGenerateClick); if (downloadPdfBtn) downloadPdfBtn.addEventListener('click', handleDownloadPdf); });