Research Paper Formatting Tool Paper Preview
Your formatted paper will appear here
Authors will be listed here
After entering your paper details, click “Format Paper” to generate a preview of your research paper in standard academic format.
Download Options
3. Results
${results.replace(/\n/g, '
')}
4. Discussion
${discussion.replace(/\n/g, '
')}
5. Conclusion
${conclusion.replace(/\n/g, '
')}
`;
// Add references if available
if (refList.length > 0) {
previewHTML += `References
`;
refList.forEach(ref => {
previewHTML += `
${ref}
`;
});
previewHTML += `
`;
}
paperPreview.innerHTML = previewHTML;
showNotification('Paper formatted successfully!', 'success');
});
// Reset form button
resetBtn.addEventListener('click', () => {
document.getElementById('paperTitle').value = '';
document.getElementById('authors').value = '';
document.getElementById('abstract').value = '';
document.getElementById('keywords').value = '';
document.getElementById('introduction').value = '';
document.getElementById('methodology').value = '';
document.getElementById('results').value = '';
document.getElementById('discussion').value = '';
document.getElementById('conclusion').value = '';
document.getElementById('references').value = '';
abstractCount.textContent = '0';
abstractCount.style.color = '#666';
paperPreview.innerHTML = `Your formatted paper will appear here
Authors will be listed here
After entering your paper details, click "Format Paper" to generate a preview of your research paper in standard academic format.
`;
showNotification('Form has been reset!', 'success');
});
// Download PDF
downloadPdf.addEventListener('click', () => {
if (paperPreview.innerHTML.includes('Your formatted paper will appear here')) {
showNotification('Please format your paper first!', 'error');
return;
}
const { jsPDF } = window.jspdf;
const doc = new jsPDF('p', 'mm', 'a4');
// Add title
const title = document.querySelector('.paper-title').textContent;
doc.setFontSize(20);
doc.text(title, 105, 20, { align: 'center' });
// Add authors
const authors = document.querySelector('.paper-authors').textContent;
doc.setFontSize(12);
doc.text(authors, 105, 30, { align: 'center' });
// Add content
doc.setFontSize(12);
const content = getTextContent();
const lines = doc.splitTextToSize(content, 180);
doc.text(lines, 20, 40);
// Save the PDF
doc.save('research_paper.pdf');
showNotification('PDF downloaded successfully!', 'success');
});
// Download Word
downloadWord.addEventListener('click', () => {
if (paperPreview.innerHTML.includes('Your formatted paper will appear here')) {
showNotification('Please format your paper first!', 'error');
return;
}
const content = getTextContent();
const blob = new Blob([content], { type: 'application/msword' });
const link = document.createElement('a');
link.href = URL.createObjectURL(blob);
link.download = 'research_paper.doc';
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
showNotification('Word document downloaded!', 'success');
});
// Helper function to get text content
function getTextContent() {
let content = '';
// Title
content += document.querySelector('.paper-title').textContent + '\n\n';
// Authors
content += document.querySelector('.paper-authors').textContent + '\n\n';
// Abstract
const abstractSection = document.querySelector('.paper-abstract');
content += 'ABSTRACT\n';
content += abstractSection.querySelector('p').textContent + '\n';
content += abstractSection.querySelector('.keywords').textContent + '\n\n';
// Sections
const sections = document.querySelectorAll('.paper-section');
sections.forEach(section => {
const heading = section.querySelector('.section-heading').textContent;
content += heading + '\n';
if (section.querySelector('.reference-list')) {
const references = section.querySelectorAll('.reference-item');
references.forEach(ref => {
content += ref.textContent + '\n';
});
} else {
content += section.querySelector('p').textContent + '\n\n';
}
});
return content;
}
// Notification function
function showNotification(message, type) {
notification.textContent = message;
notification.className = `notification ${type} show`;
setTimeout(() => {
notification.classList.remove('show');
}, 3000);
}