Research Paper Format Generator

Research Paper Format Generator

1. Title & Authors

2. Abstract

3. Core Sections

Configure paper details in the Data Configuration tab and click "Update Paper" to generate the structure here.

' + p.trim() + '

'; }).join(''); }; var generatePaper = function() { var data = { title: paperTitleInput.value || "[Research Paper Title]", authors: authorNamesInput.value || "[Author Names]", affil: authorAffilInput.value || "[Affiliation, Date]", abstract: abstractInput.value, intro: introInput.value, method: methodInput.value, results: resultsInput.value, conclusion: conclusionInput.value }; if (!data.title || !data.abstract || !data.intro) { paperContentDiv.innerHTML = '

\n Error: Please fill in the Title, Abstract, and Introduction fields in the Data Configuration tab.\n

'; return; } var paperHtml = '\n

' + data.title + '

\n
\n ' + data.authors + '
\n ' + data.affil + '\n
\n \n
Abstract
\n
\n ' + data.abstract.replace(/\n\n/g, '

').trim() + '\n
\n \n
1. Introduction
\n ' + formatParagraphs(data.intro) + '\n\n
2. Methodology
\n ' + formatParagraphs(data.method) + '\n\n
3. Results
\n ' + formatParagraphs(data.results) + '\n\n
4. Conclusion
\n ' + formatParagraphs(data.conclusion) + '\n \n \n '; paperContentDiv.innerHTML = paperHtml; }; generateBtn.addEventListener("click", function() { generatePaper(); showTab(1); // Switch to Dashboard }); // --- PDF Download --- pdfBtn.addEventListener("click", function() { var jsPDF = window.jspdf.jsPDF; var titleSlug = paperTitleInput.value.replace(/[^a-zA-Z0-9\s]/g, '').replace(/\s/g, '_').substring(0, 30) || 'Research_Paper'; var fileName = titleSlug + '.pdf'; html2canvas(exportArea, { scale: 2, useCORS: true, backgroundColor: '#ffffff' }).then(function(canvas) { var imgData = canvas.toDataURL('image/png'); var doc = new jsPDF({ orientation: 'p', unit: 'pt', format: 'letter' }); var pdfWidth = doc.internal.pageSize.getWidth(); var pdfHeight = doc.internal.pageSize.getHeight(); var imgProps = doc.getImageProperties(imgData); var imgWidth = imgProps.width; var imgHeight = imgProps.height; var margin = 40; var usableWidth = pdfWidth - (2 * margin); var ratio = usableWidth / imgWidth; var scaledHeight = imgHeight * ratio; // Handle multi-page if content exceeds page height if (scaledHeight > pdfHeight - (2 * margin)) { var pageHeight = pdfHeight - (2 * margin); var heightLeft = scaledHeight; var position = 0; while (heightLeft > 0) { doc.addImage(imgData, 'PNG', margin, position + margin, usableWidth, scaledHeight); heightLeft -= pageHeight; position -= pageHeight; if (heightLeft > 0) { doc.addPage(); } } } else { // Single page doc.addImage(imgData, 'PNG', margin, margin, usableWidth, scaledHeight); } doc.save(fileName); }).catch(function(err) { console.error("RPG PDF Error:", err); // alert("An error occurred while generating the PDF."); // Per spec }); }); // --- Initial Load --- // Render the initial sample structure on load generatePaper(); showTab(0); // Start on Config tab });
Scroll to Top