Skip to main content

pdf-watermark

為 PDF 的每一頁加入置中、半透明的對角文字浮水印。

English | 繁體中文

功能

  • 支援單一或多個 PDF 檔案。
  • 每一頁會依原始頁面尺寸個別產生浮水印。
  • 可自訂浮水印文字,並支援中文文字。
  • 長文字會依頁面可用的對角寬度自動縮小,避免超出頁面。
  • 內嵌 Noto Sans TC 字型子集,不依賴閱讀器的系統字型。
  • 原始檔案不會被覆寫。

系統需求

  • Windows、macOS 或 Linux
  • Python 3.14 或更新版本
  • uv

從 PyPI 安裝(建議)

本專案在 PyPI 上的套件名稱是 pdfcwm,安裝後的命令仍是 pdf-watermark。未指定版本時,uv 會安裝最新版本:

uv tool install pdfcwm
pdf-watermark input.pdf

不安裝、直接執行:

uvx --from pdfcwm pdf-watermark input.pdf

更新至最新版:

uv tool upgrade pdfcwm

安裝特定版本(補充)

例如安裝 0.0.5:

uv tool install pdfcwm@0.0.5

不使用 Git:下載最新版 ZIP 後執行

此 repository 為 public。以下網址會由 GitHub Latest Release 自動指向最新正式版本,不需要安裝或使用 Git。

Windows PowerShell:

Invoke-WebRequest `
  https://github.com/codemee/pdf_watermark/releases/latest/download/pdf-watermark-source.zip `
  -OutFile pdf-watermark-source.zip
Expand-Archive pdf-watermark-source.zip -DestinationPath pdf-watermark-source
Set-Location pdf-watermark-source\pdf_watermark

macOS 或 Linux:

curl -L https://github.com/codemee/pdf_watermark/releases/latest/download/pdf-watermark-source.zip \
  -o pdf-watermark-source.zip
unzip pdf-watermark-source.zip -d pdf-watermark-source
cd pdf-watermark-source/pdf_watermark

也可以在任何平台的 GitHub 頁面選擇 Code > Download ZIP,解壓後進入專案目錄。

不需安裝即可執行:

uvx --from . pdf-watermark input.pdf
uvx --from . pdf-watermark --text "Top Secret" input.pdf

若要永久安裝 pdf-watermark 指令:

uv tool install .
pdf-watermark input.pdf

也可以不手動下載或解壓,直接從 ZIP URL 安裝:

uv tool install "pdfcwm @ https://github.com/codemee/pdf_watermark/releases/latest/download/pdf-watermark-source.zip"
pdf-watermark input.pdf

以上方式都不需要 Git。uv 仍會透過 HTTPS 下載 Python 與 Python 套件相依項目。

若已安裝,使用相同網址更新至最新正式版本:

uv tool install --force "pdfcwm @ https://github.com/codemee/pdf_watermark/releases/latest/download/pdf-watermark-source.zip"

使用 Git 安裝預設分支最新內容

uv tool install git+https://github.com/codemee/pdf_watermark.git
pdf-watermark input.pdf

此方式取得預設分支的最新內容,可能包含尚未正式發布的變更。若已安裝,使用以下指令更新:

uv tool install --force git+https://github.com/codemee/pdf_watermark.git

此安裝方式需要系統上有 Git。若只想更新以 ZIP URL 安裝的版本,也可重新執行對應的 uv tool install 指令並加上 --force。

使用方式

使用預設文字 Confidential:

pdf-watermark input.pdf

指定文字:

pdf-watermark --text "機密文件" input.pdf

一次處理多個檔案:

pdf-watermark file1.pdf file2.pdf

可一次處理多個檔案;輸出預設位於原檔旁,檔名為 <原始檔名>_wm.pdf。

開發與驗證

uv sync
uv run create_test_pdf.py
uv run pdf-watermark --text "機密 Confidential" test.pdf

test.pdf 包含 A4、Letter 與 A3 三種頁面尺寸,產生的 test_wm.pdf 可用於人工檢查結果。

實作細節

請參閱實作細節解說。

字型授權

本專案隨附的 Noto Sans TC 由 Google Fonts 提供,採用 SIL Open Font License 1.1;完整條款位於 src/pdf_watermark/fonts/OFL.txt。

Metadata

Release files for pdfcwm 0.0.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pdfcwm 0.0.5
File Size Uploaded Provenance Actions
pdfcwm-0.0.5.tar.gz 4.3 MB With provenance Details for pdfcwm-0.0.5.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pdfcwm 0.0.5
File Interpreter ABI Platform Actions
pdfcwm-0.0.5-py3-none-any.whl Python 3 none any Details for pdfcwm-0.0.5-py3-none-any.whl

Total release size: 8.6 MB

Release files / pdfcwm-0.0.5.tar.gz

Download URL pdfcwm-0.0.5.tar.gz
Size 4.3 MB
Tags Source
SHA-256 checksum
How to use checksums
ea388db93dd0134ecc195b46fc45c8678545ea92df60b6336239132295d1717d
BLAKE2b-256 checksum
How to use checksums
0e1f27c0e60f254f3c6006f667b52b9a816a7276a6849ab254b17cefe6680196
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 19, 2026.

Transparency log

Release files / pdfcwm-0.0.5-py3-none-any.whl

Download URL pdfcwm-0.0.5-py3-none-any.whl
Size 4.3 MB
Tags Python 3
SHA-256 checksum
How to use checksums
00a82c711bb2b3800e2b6c0a60a1b64b7b2f036e53c8a42f48b8c027a02ef0a9
BLAKE2b-256 checksum
How to use checksums
dd6b1d9279bd1bc5234460d187fca8f52cb88837a8e6a2ca202a6973b531aa53
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 19, 2026.

Transparency log

Security for pdfcwm 0.0.5

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for pdfcwm-0.0.5.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 19, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.5 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page