-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path07_watermark.py
More file actions
61 lines (49 loc) · 1.53 KB
/
Copy path07_watermark.py
File metadata and controls
61 lines (49 loc) · 1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
"""
07 - Watermark.
Adds text watermarks with positioning, color, and opacity control.
Run:
python examples/07_watermark.py
"""
from _common import (
header, info, success, ensure_output_dir, get_sample_pdf, init_license,
)
import exis_pdfeditor
def main() -> None:
init_license()
header("Demo 07 - Watermark")
sample = get_sample_pdf()
out = ensure_output_dir()
# Basic diagonal watermark
info("Basic 'DRAFT' watermark (default style)...")
result = exis_pdfeditor.watermark(
str(sample),
str(out / "07-draft.pdf"),
"DRAFT",
)
success(f"Watermarked {result.pagesWatermarked} of {result.totalPages} pages")
# Custom: large red CONFIDENTIAL across the page
info("Large red 'CONFIDENTIAL' across the page...")
result = exis_pdfeditor.watermark(
str(sample),
str(out / "07-confidential.pdf"),
"CONFIDENTIAL",
position="across",
font_size=72,
text_color={"r": 1, "g": 0, "b": 0},
opacity=0.15,
)
success(f"Watermarked {result.pagesWatermarked} pages with red CONFIDENTIAL")
# Footer-style watermark on page 1 only
info("Footer-style watermark on page 1 only...")
result = exis_pdfeditor.watermark(
str(sample),
str(out / "07-footer-page1.pdf"),
"Internal Use Only - Page 1",
position="bottom",
font_size=14,
opacity=0.5,
page_range=[1],
)
success(f"Footer added to {result.pagesWatermarked} page(s)")
if __name__ == "__main__":
main()