admin管理员组

文章数量:1431426

I am building an application using Next.js and Sanity, where users can upload PDFs via Sanity. On the frontend, I want to display these PDFs as thumbnails (just the front page of the PDF is enough). Users should be able to click on the thumbnail to either view the full PDF in a viewer or download it.

I’ve successfully set up the Sanity backend for uploading and retrieving PDFs. However, I’m struggling to find a library or approach that can generate thumbnails from PDFs to display them on the frontend. Requirements:

Generate a thumbnail (first page) of the PDF.
Display the thumbnail on the frontend.
On click, open the full PDF for viewing or downloading.

I’ve searched for libraries but can’t find a suitable one to generate thumbnails efficiently. Any suggestions or guidance would be greatly appreciated.

Here is an example of the JSON object returned for each PDF:

{
  "_id": "887ec5b8-0145-458d-825a-6d405f60532f",
  "pdfTitle": "PDF 2024",
  "pdfFile": {
    "asset": {
      "url": ";
    }
  }
}

本文标签: javascriptHow to Generate PDF Thumbnails for Frontend Display in a NextjsSanity ApplicationStack Overflow