Online Lecture Note Organizer

Online Lecture Note Organizer

${note.content}

`; break; case 'li': html += `
  • ${note.content}
  • `; break; } }); if (inList) { html += ``; } organizedNotesDisplay.innerHTML = html; }; // --- PDF Generation --- const generatePdf = () => { if (!organizedNotesData) { alert("No notes to download. Please organize your notes first."); return; } const { jsPDF } = window.jspdf; const buildPdfReportHtml = (data) => { const date = new Date().toLocaleDateString('en-US', { year: 'numeric', month: 'long', day: 'numeric' }); let inList = false; let notesHtml = ''; data.notes.forEach(note => { if (note.type === 'li' && !inList) { notesHtml += `
      `; inList = true; } else if (note.type !== 'li' && inList) { notesHtml += `
    `; inList = false; } switch(note.type) { case 'h2': notesHtml += `

    ${note.content}

    `; break; case 'h3': notesHtml += `

    ${note.content}

    `; break; case 'p': notesHtml += `

    ${note.content}

    `; break; case 'li': notesHtml += `
  • ${note.content}
  • `; break; } }); if (inList) notesHtml += ``; return `

    ${data.title}

    Notes Organized on: ${date}

    ${notesHtml}
    `; }; pdfRenderContainer.innerHTML = buildPdfReportHtml(organizedNotesData); html2canvas(pdfRenderContainer, { scale: 2, useCORS: true }) .then(canvas => { const imgData = canvas.toDataURL('image/png'); const pdf = new jsPDF({ orientation: 'portrait', unit: 'px', format: 'a4' }); const pdfWidth = pdf.internal.pageSize.getWidth(); const canvasWidth = canvas.width; const canvasHeight = canvas.height; const ratio = canvasWidth / canvasHeight; const widthInPdf = pdfWidth; const heightInPdf = widthInPdf / ratio; pdf.addImage(imgData, 'PNG', 0, 0, widthInPdf, heightInPdf); pdf.save(`Notes_${organizedNotesData.title.replace(/\s+/g, '_')}.pdf`); }); }; // --- Event Listeners --- inputTabBtn.addEventListener('click', () => switchToTab('input')); viewTabBtn.addEventListener('click', () => switchToTab('view')); downloadPdfBtn.addEventListener('click', generatePdf); });
    Scroll to Top