-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
93 lines (72 loc) · 3.11 KB
/
app.py
File metadata and controls
93 lines (72 loc) · 3.11 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
import os, sys, webview
from threading import Timer
if getattr(sys, 'frozen', False):
try:
import pyi_splash
pyi_splash.close()
except:
pass
def resource_path(relative_path):
"""
Get the absolute path to a resource. Works for dev and PyInstaller.
When frozen, PyInstaller stores assets in sys._MEIPASS.
"""
try:
# Path for PyInstaller
base_path = sys._MEIPASS
except Exception:
# Path for regular execution (development)
base_path = os.path.abspath(".")
return os.path.join(base_path, relative_path)
# Use the resolved path for the templates directory
TEMPLATES_DIR = resource_path("templates")
UPLOAD_DIR = resource_path("uploads")
OUTPUT_DIR = resource_path("redacted")
root_dir = resource_path("")
wait_time = 0.2
def home_page():
act_wind = webview.active_window()
if act_wind:
Timer(wait_time, lambda: act_wind.load_url('home_page.html')).start()
def redact_page():
act_wind = webview.active_window()
if act_wind:
Timer(wait_time, lambda: act_wind.load_url('redact.html')).start()
def organize_page():
act_wind = webview.active_window()
if act_wind:
Timer(wait_time, lambda: act_wind.load_url('organize.html')).start()
def form_page():
act_wind = webview.active_window()
if act_wind:
Timer(wait_time, lambda: act_wind.load_url('form.html')).start()
def crop_page():
act_wind = webview.active_window()
if act_wind:
Timer(wait_time, lambda: act_wind.load_url('crop.html')).start()
def split_page():
act_wind = webview.active_window()
if act_wind:
Timer(wait_time, lambda: act_wind.load_url("split.html")).start()
def imgtopdf_page():
act_wind = webview.active_window()
if act_wind:
Timer(wait_time, lambda: act_wind.load_url("imgtopdf.html")).start()
def license_page():
act_wind = webview.active_window()
if act_wind:
act_wind.load_url("license.html")
if __name__ == "__main__":
from backend_api import crop, organize_pdf, redact_pdf, fill_form, watermark, split, imagetopdf
webview.settings['OPEN_EXTERNAL_LINKS_IN_BROWSER'] = False
window = webview.create_window('PDF92', 'home_page.html', maximized=True, text_select =True, zoomable=True)
window.expose(
redact_pdf.get_bbox, redact_pdf.get_single_page_bbox, redact_pdf.redact_pdf, redact_pdf.save_file_dialog, redact_pdf.open_containing_folder,
organize_pdf.reset, organize_pdf.open_pdf_organize, organize_pdf.organize_pdf, organize_pdf.save_file_dialog,
fill_form.open_file_dialog, fill_form.load_pdf, fill_form.save_pdf,
crop.get_file_path, crop.save_file_path, crop.load_pdf_as_base64, crop.process_crop,
split.select_pdf_file, split.process_splits, split.save_output_file,
imagetopdf.select_images, imagetopdf.process_and_save_pdf,
home_page, redact_page, organize_page, form_page, crop_page, split_page, imgtopdf_page, license_page
)
webview.start(ssl=True, http_server=False, icon='pdf92.ico')