-
Notifications
You must be signed in to change notification settings - Fork 1
/
stamp.py
25 lines (22 loc) · 836 Bytes
/
stamp.py
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
# -*- coding: utf-8 -*-
import subprocess
def stamp(pdf_path, stamp_path, output_folder):
output = output_folder / pdf_path.name
cmd = ['pdftk.exe', str(pdf_path), 'stamp', str(stamp_path), 'output', str(output)]
subprocess_popen(cmd)
def subprocess_popen(cmd):
startupinfo = subprocess.STARTUPINFO()
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
startupinfo.wShowWindow = subprocess.SW_HIDE
proc = subprocess.Popen(
cmd,
encoding='cp932',
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
startupinfo=startupinfo
)
stdout, stderr = proc.communicate(timeout=1000)
return stdout, stderr
if __name__ == '__main__':
from pathlib import Path
stamp(Path('Y19X02AUA501.pdf'), Path('__test__.pdf'), Path('output/'))