Spaces:
Sleeping
Sleeping
t commited on
Commit ·
fb7e5e9
1
Parent(s): daae428
fix: add missing uuid import in pdf_ops.py to resolve 500 error in merge and resize operations
Browse files- routes/pdf_ops.py +6 -2
routes/pdf_ops.py
CHANGED
|
@@ -1,4 +1,5 @@
|
|
| 1 |
import os
|
|
|
|
| 2 |
import fitz
|
| 3 |
import base64
|
| 4 |
from datetime import datetime
|
|
@@ -193,8 +194,11 @@ def print_pdfs():
|
|
| 193 |
if os.path.exists(path):
|
| 194 |
with fitz.open(path) as d:
|
| 195 |
if len(d) > 0:
|
| 196 |
-
|
| 197 |
-
|
|
|
|
|
|
|
|
|
|
| 198 |
merged.insert_pdf(d)
|
| 199 |
tmp_name = f'printed_documents_{datetime.now().strftime("%Y%m%d%H%M%S")}.pdf'
|
| 200 |
tmp_path = os.path.join(current_app.config['TEMP_FOLDER'], tmp_name)
|
|
|
|
| 1 |
import os
|
| 2 |
+
import uuid
|
| 3 |
import fitz
|
| 4 |
import base64
|
| 5 |
from datetime import datetime
|
|
|
|
| 194 |
if os.path.exists(path):
|
| 195 |
with fitz.open(path) as d:
|
| 196 |
if len(d) > 0:
|
| 197 |
+
try:
|
| 198 |
+
# Use insert_text which is simpler and less prone to font errors
|
| 199 |
+
d[0].insert_text(fitz.Point(20, 15), f"Subject: {p['subject']} | File: {p['filename']}", fontsize=6, color=(0, 0, 0))
|
| 200 |
+
except Exception as e:
|
| 201 |
+
current_app.logger.error(f"Could not insert header for {p['filename']}: {e}")
|
| 202 |
merged.insert_pdf(d)
|
| 203 |
tmp_name = f'printed_documents_{datetime.now().strftime("%Y%m%d%H%M%S")}.pdf'
|
| 204 |
tmp_path = os.path.join(current_app.config['TEMP_FOLDER'], tmp_name)
|