-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path08_stamp.py
More file actions
53 lines (41 loc) · 1.43 KB
/
Copy path08_stamp.py
File metadata and controls
53 lines (41 loc) · 1.43 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
"""
08 - Stamp (PDF overlay / underlay).
Stamp another PDF on top of (overlay) or behind (underlay) a document. Useful
for adding letterheads, backgrounds, branded headers, or watermark layers
that are themselves vector PDFs rather than text.
Run:
python examples/08_stamp.py
Note: this demo uses the same sample PDF as both the base document AND the
stamp source so it can run without needing two separate files. In production
you would use a dedicated letterhead/background PDF.
"""
from _common import (
header, info, success, ensure_output_dir, get_sample_pdf, init_license,
)
import exis_pdfeditor
def main() -> None:
init_license()
header("Demo 08 - Stamp (overlay / underlay)")
sample = get_sample_pdf()
out = ensure_output_dir()
# Overlay (stamp on top)
info("Stamping the sample on top of itself (overlay)...")
result = exis_pdfeditor.stamp(
str(sample),
str(out / "08-overlay.pdf"),
str(sample),
mode="overlay",
)
success(f"Overlay applied to {result.pagesStamped} page(s)")
# Underlay (stamp behind content) with opacity
info("Stamping behind content (underlay) at 30% opacity...")
result = exis_pdfeditor.stamp(
str(sample),
str(out / "08-underlay.pdf"),
str(sample),
mode="underlay",
opacity=0.3,
)
success(f"Underlay applied to {result.pagesStamped} page(s)")
if __name__ == "__main__":
main()