hereisSwapnil / ExamTime

Share/Download notes PDF helps during exams
https://exam-time.vercel.app
MIT License
55 stars 116 forks source link

Notes thumnail #228

Closed Tapesh-1308 closed 4 months ago

Tapesh-1308 commented 4 months ago

Description

This pull request introduces a new function, createThumbnailFromPDF, which generates a thumbnail image from the first page of a given PDF file using the pdfjs library. Key updates include reading the PDF as an ArrayBuffer, rendering the first page onto a canvas, converting the canvas to a PNG data URL, and updating the state with the thumbnail URL.

Resolves: 61

This PR introduces a new function createThumbnailFromPDF to generate a thumbnail image from the first page of a given PDF file using the pdfjs library. The key updates include:

-File Reading: Utilizes FileReader to read the PDF file as an ArrayBuffer.

-PDF.js Integration: Configures pdfjs to use a CDN worker script for handling PDF operations.

-Rendering PDF Page: Extracts the first page of the PDF and renders it onto a dynamically created canvas element.

-Thumbnail Generation: Converts the rendered canvas into a Data URL representing a PNG image of the PDF's first page.

-State Update: Sets the generated thumbnail URL to state using setThumbnailURL. These changes enhance the application's functionality by providing a visual preview of uploaded PDF files.

Additional Changes:

Checklist

Before submitting this pull request, kindly verify that the ensuing checkpoints have been reached.


I certify that I have carried out the relevant checks and provided the requisite screenshot for validation by submitting this pull request.

vercel[bot] commented 4 months ago

@Tapesh-1308 is attempting to deploy a commit to the swapnilsingh99's projects Team on Vercel.

A member of the Team first needs to authorize it.

hereisSwapnil commented 4 months ago

61