最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to Generate PDF Thumbnails for Frontend Display in a Next.js + Sanity Application? - Stack Overflow

programmeradmin1浏览0评论

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": ";
    }
  }
}
发布评论

评论列表(0)

  1. 暂无评论