WeKnora
Tencent
Open-source LLM knowledge platform: turn raw documents into a queryable RAG, an autonomous reasoning agent, and a self-maintaining Wiki.
PROJECT TOPICS
INSTALL REFERENCE
dsh plugin --profile web add github:Lindong-K/doc-watermark
该命令指向仓库当前默认分支;尚无绑定当前 commit 的完整验证结果。
PROJECT README
A professional, reading-friendly watermark for PDF / HTML / DOCX / TXT / Markdown, with built-in verification that proves the watermark never touches the reading area.
Design principle (industry standard, see 中文说明): the watermark must never enter the content area. Margin-first placement is preferred; full-page tiled patterns are the most intrusive option and are forbidden.
| Format | Method |
|---|---|
reportlab + pypdf overlay drawn at known page coordinates inside the page margins (left vertical text rotated 90° as a single run + bottom-right corner mark, 32% opacity by default). No CSS print positioning. |
|
| DOCX | Word-native VML watermark in the header layer (z-index below body text), light fill — no reliance on Word's unreliable transparency. |
| HTML | CSS screen-only watermark (content layer above it, z-index:-1), hidden on @media print. |
| TXT / MD | Header/footer signature lines. |
*_wm2, *_wm3 … and verifies the file
timestamp after writing (no silent failures).pip install -r requirements.txt
python demo.py # generates neutral samples into ./examples and watermarks them
One-shot CLI:
python wm_engine.py config.json
config.json:
{
"src": "C:\\path\\to\\doc.pdf",
"watermark_text": "DeepSeek AI · Original",
"position": "left_vertical+bottom_right",
"color": "#0969DA",
"opacity": 0.32,
"verify": true
}
stdout returns one JSON report containing a ready-to-paste Markdown report and the per-page pixel-diff table.
| Key | Default | Meaning |
|---|---|---|
src |
— | input document path (.pdf / .html / .docx / .txt / .md) |
dst |
*_wm.ext |
optional custom output path |
watermark_text |
DeepSeek AI · Original |
watermark string |
position |
left_vertical+bottom_right |
left_vertical / bottom_right / left_vertical+bottom_right / center_diagonal / header_footer |
color |
#0969DA |
hex color |
opacity |
0.32 (overlay 0.05) |
margin tier; center_diagonal is clamped to ≤ 0.06 and drawn under the content layer |
font_size |
adaptive | font size (pt); per-format defaults otherwise |
font |
auto | PDF: STSong-Light for CJK, Helvetica otherwise |
verify |
true |
run the render-diff verification (PDF) |
page_margin_pt |
28.8 |
page margin used by the content-area assertion (A4 default 0.4in) |
Sample output: examples/verification-report.md
wm_plugin.host.js is the Host half of a dynamic Cordis plugin for
DeepSeek Harness that registers a model-callable tool
watermark_document. It pipes the engine via stdin and configuration via the WM_CONFIG
environment variable — no temporary files are written. It locates wm_engine.py next to the
target document or in the workspace root.
专业、不干扰阅读的文档水印引擎:PDF / HTML / DOCX / TXT / MD,自带客观验证。
position:fixed 打印(定位不可靠、@page 边距会让其整体消失)——必须用
reportlab+pypdf 按已知页面坐标叠加。pip install -r requirements.txt
python demo.py
demo.py 会生成中性示例文档(examples/sample.*)并演示加水印与逐页 diff 验证,
输出报告见 examples/verification-report.md。
z-index:-1,内容层之上),打印时隐藏。1.5× 渲染"无水印 vs 有水印"两份 PDF 逐页像素 diff,断言差异像素 100% 位于页边距、正文区 0 差异; 覆盖式水印过淡时回退到内容流文本检出。实测 9 页文档全部通过。
写入前用独占字节锁探测文件占用,被占用自动改用 _wm2/_wm3;写后校验非空 + 时间戳,防静默失败。
wm_plugin.host.js 是动态 Cordis 插件的 Host 半区,注册模型可调用的 watermark_document 工具;
引擎经 stdin 传入、配置走 WM_CONFIG 环境变量,全程不写临时文件。引擎脚本放在文档同目录或
工作区根目录即可。
CLASSIFICATION EVIDENCE
系统优先读取 GitHub Topics,再与站内分类词典和词根规则比对。当前命中: document-watermark、pdf-watermark、pypdf。