Sociology Paper Generator

Sociology Paper Generator

Create structured outlines for your sociology papers with theoretical frameworks.

Your Paper Title Will Appear Here

Configure your paper's parameters and click "Generate Paper" to see the outline here.

${conclusion}

`; textForPdf.push({ type: 'h3', content: 'Conclusion' }, { type: 'p', content: conclusion }); // Update state and UI generatedContent = { title, html, text: textForPdf }; paperTitleOutput.textContent = title; paperBodyOutput.innerHTML = generatedContent.html; switchTab('paper'); }; // --- PDF Generation --- const generatePDF = () => { const { jsPDF } = window.jspdf; if (!generatedContent.title) { alert("Please generate a paper outline first."); return; } const doc = new jsPDF({ orientation: 'portrait', unit: 'mm', format: 'a4' }); // Set fonts (jsPDF has built-in serif fonts) const bodyFont = 'times'; const headingFont = 'helvetica'; // --- Page Numbering Footer --- const addFooter = () => { const pageCount = doc.internal.getNumberOfPages(); for (let i = 1; i <= pageCount; i++) { doc.setPage(i); doc.setFont(bodyFont, 'italic'); doc.setFontSize(10); doc.setTextColor(100); doc.text(String(i), doc.internal.pageSize.getWidth() / 2, 285, { align: 'center' }); } }; // --- Page 1: Title Page --- doc.setFont(headingFont, 'bold'); doc.setFontSize(18); doc.text(generatedContent.title, 105, 60, { align: 'center', maxWidth: 180 }); doc.setFont(bodyFont, 'normal'); doc.setFontSize(12); doc.text("by", 105, 80, { align: 'center' }); doc.text("A. N. Author", 105, 87, { align: 'center' }); doc.text("University of Sociology", 105, 100, { align: 'center' }); doc.text(`Date: ${new Date().toLocaleDateString('en-US')}`, 105, 107, { align: 'center' }); // --- Content Pages --- doc.addPage(); const leftMargin = 20; const rightMargin = 20; const usableWidth = doc.internal.pageSize.getWidth() - leftMargin - rightMargin; let yPosition = 30; generatedContent.text.forEach(item => { if (yPosition > 260) { // Check for page break before printing doc.addPage(); yPosition = 30; } if (item.type === 'h3') { doc.setFont(headingFont, 'bold'); doc.setFontSize(14); const lines = doc.splitTextToSize(item.content, usableWidth); doc.text(lines, leftMargin, yPosition); yPosition += (lines.length * 7) + 2; // Extra space after heading } else if (item.type === 'p') { doc.setFont(bodyFont, 'normal'); doc.setFontSize(12); const lines = doc.splitTextToSize(item.content, usableWidth); // Add paragraph indentation lines[0] = " " + lines[0]; doc.text(lines, leftMargin, yPosition); yPosition += (lines.length * 5.5) + 5; // Extra space after paragraph } }); addFooter(); doc.save(`${generatedContent.title.replace(/\s+/g, '_')}.pdf`); }; // --- Event Listeners --- tabPaper.addEventListener('click', () => switchTab('paper')); tabConfig.addEventListener('click', () => switchTab('config')); nextBtn.addEventListener('click', () => switchTab('config')); prevBtn.addEventListener('click', () => switchTab('paper')); generateBtn.addEventListener('click', generatePaperContent); downloadPdfBtn.addEventListener('click', generatePDF); loadSampleBtn.addEventListener('click', () => { const sampleContainer = document.getElementById('sample-data'); paramTitle.value = sampleContainer.querySelector('[data-id="title"]').textContent; paramThesis.value = sampleContainer.querySelector('[data-id="thesis"]').textContent; paramTheory.value = sampleContainer.querySelector('[data-id="theory"]').dataset.value; paramParagraphs.value = sampleContainer.querySelector('[data-id="paragraphs"]').textContent; }); // --- Initializer --- switchTab('paper'); // Start on the output tab });
Scroll to Top