Skip to content

[FEATURE] Add a "Download as PDF" button #342

Description

@Dev1822

Feature Description

Add a "Download as PDF" button to all course chapter pages. When a user clicks this button, the application will capture the chapter's content, apply print-optimized formatting (removing navigation bars, sidebars, and footers), compile it into a high-quality PDF document, and automatically trigger a download to the student's device.

Problem It Solves

Many students prefer to annotate their study materials using tablet applications (like iPad/GoodNotes) or prefer printing physical copies for distraction-free offline studying. Currently, students are forced to use the browser's native print dialog, which often results in messy layouts, cut-off text, and unwanted UI elements being included in the printout. A dedicated PDF export feature provides a clean, standardized, and highly readable document tailored specifically for studying.

Proposed Solution

  1. Client-Side PDF Generation: Utilize a lightweight client-side library such as html2canvas paired with jspdf (or the all-in-one html2pdf.js). This generates the PDF directly in the student's browser, meaning there is zero strain on your servers and it works instantly.
  2. Print-Optimized Styling: Target specifically the <div className="course-content"> wrapper that holds your notes. The script will be configured to ignore the Navbar and Footer components, ensuring only the educational content is captured.
  3. UI Integration: Add a clean download button using your existing lucide-react icon library (e.g., the Download or FileText icon) at the top right of the chapter layout.
  4. Dynamic Naming: The resulting file will be dynamically named based on the semester and chapter (e.g., openCSE_Semester3_COA_Module1.pdf) so students can easily organize their downloaded files.

Additional Context

  • Because this relies on client-side JavaScript, it pairs perfectly with your current Next.js architecture and requires no backend APIs.
  • We can optionally configure jspdf to automatically inject an "openCSE" watermark or page numbers at the bottom of every exported PDF page for branding.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions