Spaces:
Sleeping
Sleeping
Update pdf.py
Browse files
pdf.py
CHANGED
|
@@ -2,7 +2,9 @@
|
|
| 2 |
import re
|
| 3 |
import tempfile
|
| 4 |
from typing import Any, Dict
|
| 5 |
-
|
|
|
|
|
|
|
| 6 |
from reportlab.lib import colors
|
| 7 |
from reportlab.lib.pagesizes import A4
|
| 8 |
from reportlab.lib.units import inch
|
|
@@ -99,7 +101,12 @@ def generate_recipe_pdf(recipe_json):
|
|
| 99 |
if not recipes:
|
| 100 |
return None
|
| 101 |
|
| 102 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 103 |
|
| 104 |
doc = SimpleDocTemplate(
|
| 105 |
pdf_path,
|
|
|
|
| 2 |
import re
|
| 3 |
import tempfile
|
| 4 |
from typing import Any, Dict
|
| 5 |
+
import os
|
| 6 |
+
import uuid
|
| 7 |
+
import tempfile
|
| 8 |
from reportlab.lib import colors
|
| 9 |
from reportlab.lib.pagesizes import A4
|
| 10 |
from reportlab.lib.units import inch
|
|
|
|
| 101 |
if not recipes:
|
| 102 |
return None
|
| 103 |
|
| 104 |
+
|
| 105 |
+
tmp_dir = tempfile.gettempdir()
|
| 106 |
+
|
| 107 |
+
pdf_path = os.path.join( tmp_dir, f"recipe_report_{uuid.uuid4().hex}.pdf")
|
| 108 |
+
|
| 109 |
+
|
| 110 |
|
| 111 |
doc = SimpleDocTemplate(
|
| 112 |
pdf_path,
|