不能。PDF 權限是 reader 應遵守的限制,不是無法破解的存取控制。真正保護內容機密的是加密後的開啟密碼,請使用夠長、不易猜測的密碼。
curl -fsSL https://raw.githubusercontent.com/doggy8088/pdf-encrypt/main/install.sh | sh
下載對應平台的執行檔、驗證 SHA-256,再安裝到 ~/.local/bin。指定版本與目錄:| sh -s -- --version 0.3.1 --to ~/bin。
irm https://raw.githubusercontent.com/doggy8088/pdf-encrypt/main/install.ps1 | iex
在 PowerShell 執行。安裝到 %LOCALAPPDATA%\Programs\pdf-encrypt\bin,並把該目錄加入使用者 PATH。
npm install -g @willh/pdf-encrypt
需要 Node.js 18 以上。npm 只下載符合目前平台的執行檔,不執行 postinstall。不安裝直接試用:npx @willh/pdf-encrypt --help。
cargo install pdf-encrypt --locked
已安裝 Rust 工具鏈時,從 crates.io 編譯安裝。
三步蓋好印章
安裝與加密為實測:安裝指令稿在一般網路下約 4 秒;61 頁、3.5 MB 的 PDF 以 AES-256 加密 0.52 秒。組指令的時間為估計。
五種常見情境
$ pdf-encrypt encrypt -i report.pdf -p "$PDF_OPEN_PASSWORD"
已完成加密:report_encrypted.pdf
operation: encrypt
algorithm: aes-256
input_encrypted: false
output_encrypted: true
pages: 61
$ pdf-encrypt encrypt -i report.pdf \
-o report_readonly.pdf \
--owner-password "$PDF_OWNER_PASSWORD" --read-only
已完成加密:report_readonly.pdf
operation: encrypt
algorithm: aes-256
output_encrypted: true
pages: 61
$ pdf-encrypt decrypt -i report_encrypted.pdf -p "$PDF_PASSWORD"
已完成解密:report_encrypted_decrypted.pdf
operation: decrypt
input_encrypted: true
output_encrypted: false
pages: 61
$ pdf-encrypt info -i annual_encrypted.pdf -p "$PDF_PASSWORD" --json
{
"document_info": {
"author": "Will 保哥",
"keywords": "PDF, 加密",
"title": "年度報告"
},
"input_encrypted": true,
"pages": 61,
"pdf_version": "2.0"
}
$ pdf-encrypt encrypt -i report_encrypted.pdf \
-o report_rekeyed.pdf --algorithm aes-128 \
--input-open-password "$PDF_PASSWORD" -p "$PDF_OPEN_PASSWORD"
已完成加密:report_rekeyed.pdf
algorithm: aes-128
input_encrypted: true
output_encrypted: true
原檔保留,另存為 report_encrypted.pdf;擁有者密碼自動與開啟密碼相同。
組合你的指令
勾選需要的選項,產生可直接貼到終端機的指令。一切都在瀏覽器裡完成,不會上傳檔案,也不會儲存密碼。
一個工具,六件事
每一件都能單獨使用,也能在同一個指令裡一起完成。
-

預設 AES-256
PDF 2.0 標準安全處理器;需要相容舊版 reader 時可改用 AES-128 或 RC4。
-

八種檢視權限
列印、複製、修改、註解、填表、組合頁面等逐項允許或禁止,或用
--read-only一次設為唯讀。 -

重新加密
以舊密碼開啟已加密的 PDF,直接換成新密碼或新演算法。
-

讀寫文件屬性
info --json讀取 Document Info 與 XMP;edit只改指定欄位,保留既有加密。 -

單一執行檔
以 Rust 與
lopdf直接讀寫 PDF,不呼叫 qpdf、Ghostscript 或 pdftk。 -

適合 AI 代理與 CI
JSON 輸出、明確的結束碼與
--force非互動模式,並附 Agent Skill。
演算法與權限
演算法
aes-256預設,新文件建議使用PDF 2.0aes-128相容較舊的 PDF readerPDF 1.5rc4-128舊系統相容用途PDF 1.4rc4-40僅供極舊系統,不建議PDF 1.4
檢視權限
- 列印文件
print - 高品質列印
high-quality-print - 修改內容
modify - 複製或擷取內容
copy - 新增或修改註解
annotate - 填寫表單
fill-forms - 輔助使用的內容擷取
accessibility - 組合頁面或大綱
assemble
密碼組合
- 只設開啟密碼:擁有者密碼自動相同,知道密碼的人有完整權限機密
- 只設擁有者密碼:任何人都能開啟,但 reader 套用權限限制唯讀發布
- 兩者都設:開啟密碼受限,擁有者密碼享完整權限分級
常見問題
不會。網站只在瀏覽器裡產生指令文字,實際的加密與解密都由你電腦上的 pdf-encrypt 執行。
不能。decrypt 需要正確的開啟密碼或擁有者密碼。只有權限限制、沒有開啟密碼的 PDF,可以省略 --password 直接解密。
預設不會。未指定輸出時另存為 <原檔名>_encrypted.pdf 等新檔;只有加上 --in-place,才會在寫入成功後取代原檔。
macOS(Apple 晶片與 Intel)、Linux(x64 與 ARM64,glibc 與 musl 皆可)、Windows(x64 與 ARM64)。npm 與安裝指令稿會自動選擇對應的執行檔。