PDF.js Direct Downloader

Adds a download button to PDF.js viewers that saves the original PDF file

作者
skl49
日安装量
0
总安装量
0
评分
0 0 0
版本
1.0
创建于
2025-08-18
更新于
2025-08-18
大小
1.9 KB
许可证
MIT
适用于
所有网站

PDF.js Direct Downloader

PDF.js Direct Downloader adds a convenient Download PDF button to any webpage that uses PDF.js as its PDF viewer.

Normally, some websites hide or disable the download option in PDF.js, making it difficult to save the original file. This script fixes that by injecting a button that lets you download the currently opened PDF directly from your browser.


✨ Features

  • ✅ Detects if a page is using PDF.js
  • ✅ Adds a floating “Download PDF” button in the top-right corner of the screen
  • ✅ Saves the PDF as a file (document.pdf) with one click
  • ✅ Works even if the site’s native download button is disabled or hidden
  • ✅ Lightweight and runs automatically

📌 How It Works

  • The script waits until PDF.js is loaded on the page.
  • Once detected, it inserts a custom button in the corner of the viewer.
  • When clicked, it uses the PDF.js API to extract the binary PDF data and triggers a browser download.
  • The file will be saved as document.pdf by default.

⚠️ Limitations

  • Currently, the filename is always document.pdf.
  • Some websites may override or customize PDF.js in ways that break detection.
  • If a site doesn’t use PDF.js, the button will not appear.

🛠️ Compatibility

  • Works in Chrome, Firefox, Edge, and other browsers with Tampermonkey.
  • Should work on any website that embeds PDFs with PDF.js.