rairo commited on
Commit
a0d5656
·
verified ·
1 Parent(s): 2500be7

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +7 -7
main.py CHANGED
@@ -17,9 +17,11 @@ import logging
17
  import traceback
18
  from video_gen import create_video
19
  import zipfile
20
- from fpdf import FPDF
21
-
22
 
 
 
 
23
  # Initialize Flask app and CORS
24
  app = Flask(__name__)
25
  CORS(app)
@@ -680,13 +682,11 @@ def download_story_archive(story_id):
680
  blob = bucket.blob(blob_path)
681
  image_data = blob.download_as_bytes()
682
 
683
- # Save the image to a temp file so FPDF can read it
684
- temp_img_path = f"/tmp/{uuid.uuid4().hex}.jpg"
685
- with open(temp_img_path, "wb") as f:
686
- f.write(image_data)
687
 
688
  # Insert the image at (x=10, y=None => next line), width=100
689
- pdf.image(temp_img_path, x=10, y=None, w=100)
690
  # Clean up temp file
691
  os.remove(temp_img_path)
692
 
 
17
  import traceback
18
  from video_gen import create_video
19
  import zipfile
20
+ from fpdf2 import FPDF
 
21
 
22
+ pdf = FPDF(auto_page_break=True, margin=15)
23
+ pdf.add_page()
24
+ pdf.set_font("Arial", size=12)
25
  # Initialize Flask app and CORS
26
  app = Flask(__name__)
27
  CORS(app)
 
682
  blob = bucket.blob(blob_path)
683
  image_data = blob.download_as_bytes()
684
 
685
+ image_stream = io.BytesIO(image_data)
686
+
 
 
687
 
688
  # Insert the image at (x=10, y=None => next line), width=100
689
+ pdf.image(image_stream, x=10, y=None, w=100)
690
  # Clean up temp file
691
  os.remove(temp_img_path)
692