`;
return;
}
this.analysisResults.forEach(result => {
const lineEl = document.createElement('div');
lineEl.className = 'mb-4';
lineEl.innerHTML = `
"${result.line}"
`; result.suggestions.forEach(sug => { const sugEl = document.createElement('div'); sugEl.className = `suggestion-card suggestion-${sug.type}`; sugEl.innerHTML = `${sug.title}
${sug.text}
`; lineEl.appendChild(sugEl); }); this.dom.resultsContent.appendChild(lineEl); }); }, generatePdf() { if (!this.analysisResults || this.analysisResults.length === 0) { alert('Please enhance some dialogue first to generate a report.'); return; } const { jsPDF } = window.jspdf; const pdf = new jsPDF({ unit: 'pt', format: 'a4' }); const margin = 40; let cursorY = 60; pdf.setFont('helvetica', 'bold'); pdf.setFontSize(20); pdf.text("Dialogue Enhancement Report", margin, cursorY); cursorY += 40; this.analysisResults.forEach(result => { if (cursorY > 780) { // New page check pdf.addPage(); cursorY = 40; } pdf.setFont('times', 'italic'); pdf.setFontSize(12); pdf.setTextColor(40, 40, 40); const lineText = `"${result.line}"`; const splitLine = pdf.splitTextToSize(lineText, pdf.internal.pageSize.getWidth() - (2 * margin)); pdf.text(splitLine, margin, cursorY); cursorY += splitLine.length * 12 + 10; result.suggestions.forEach(sug => { pdf.setFont('helvetica', 'bold'); pdf.setFontSize(10); pdf.setTextColor(100, 100, 100); pdf.text(`Suggestion: ${sug.title}`, margin + 15, cursorY); cursorY += 15; pdf.setFont('helvetica', 'normal'); pdf.setTextColor(40, 40, 40); const sugText = sug.text.replace(/|<\/strong>/g, ''); // strip html const splitSug = pdf.splitTextToSize(sugText, pdf.internal.pageSize.getWidth() - (2 * margin + 15)); pdf.text(splitSug, margin + 15, cursorY); cursorY += splitSug.length * 10 + 10; }); cursorY += 15; // Extra space between sections }); pdf.save('Dialogue-Enhancement-Report.pdf'); } }; app.init(); });