PDF 水印添加 / 去除命令行工具。
- 添加水印:基于
reportlab生成水印 PDF,再通过PyPDF2合并到目标 PDF - 去除水印:基于
PyMuPDF将页面栅格化,剔除浅色像素,再重组为 PDF
依赖管理使用 uv。
uv sync --extra dev# 添加水印
uv run xpdf watermark add <input.pdf> "<水印内容>"
# 添加水印并指定输出文件
uv run xpdf watermark add <input.pdf> "<水印内容>" --output <output.pdf>
# 去除水印
uv run xpdf watermark remove <input.pdf>uv run pytest # 运行测试
uv run pytest --cov=xpdf tests/ # 覆盖率
uv run pre-commit run --all-files # 全量 pre-commit 检查