LuisBlanche
commited on
Commit
•
54e5853
1
Parent(s):
42d4976
Update app.py
Browse files
app.py
CHANGED
@@ -279,16 +279,18 @@ css = """
|
|
279 |
}
|
280 |
"""
|
281 |
|
|
|
282 |
def convert_pdf_to_image(pdf_buffer):
|
283 |
-
from reportlab.pdfgen.canvas import Canvas
|
284 |
from reportlab.graphics.renderPM import drawToPIL
|
285 |
from reportlab.graphics.shapes import Drawing
|
|
|
286 |
|
287 |
buffer = BytesIO()
|
288 |
canvas = Canvas(buffer, pagesize=A4)
|
|
|
|
|
|
|
289 |
|
290 |
-
# Draw some content on the canvas
|
291 |
-
drawing = Drawing(200, 100)
|
292 |
canvas.drawText("Preview of the PDF")
|
293 |
canvas.showPage()
|
294 |
canvas.save()
|
@@ -297,6 +299,7 @@ def convert_pdf_to_image(pdf_buffer):
|
|
297 |
pil_image = drawToPIL(drawing)
|
298 |
return pil_image
|
299 |
|
|
|
300 |
def fetch_votes(deputy_name):
|
301 |
pdfposter = PDFPoster(deputy_name)
|
302 |
votes = pdfposter.retrieve_deputy_data()
|
@@ -314,7 +317,7 @@ def generate_poster(deputy_name, message_1, message_2, vote_list):
|
|
314 |
|
315 |
pdfposter = PDFPoster(deputy_name)
|
316 |
pdfposter.retrieve_deputy_data()
|
317 |
-
|
318 |
pdf_path = f"/data/{deputy_name}.pdf"
|
319 |
with open(pdf_path, "wb") as f:
|
320 |
f.write(pdf_buffer.getvalue())
|
|
|
279 |
}
|
280 |
"""
|
281 |
|
282 |
+
|
283 |
def convert_pdf_to_image(pdf_buffer):
|
|
|
284 |
from reportlab.graphics.renderPM import drawToPIL
|
285 |
from reportlab.graphics.shapes import Drawing
|
286 |
+
from reportlab.pdfgen.canvas import Canvas
|
287 |
|
288 |
buffer = BytesIO()
|
289 |
canvas = Canvas(buffer, pagesize=A4)
|
290 |
+
from reportlab.graphics.renderPM import drawToPIL
|
291 |
+
from reportlab.graphics.shapes import Drawing
|
292 |
+
from reportlab.pdfgen.canvas import Canvas
|
293 |
|
|
|
|
|
294 |
canvas.drawText("Preview of the PDF")
|
295 |
canvas.showPage()
|
296 |
canvas.save()
|
|
|
299 |
pil_image = drawToPIL(drawing)
|
300 |
return pil_image
|
301 |
|
302 |
+
|
303 |
def fetch_votes(deputy_name):
|
304 |
pdfposter = PDFPoster(deputy_name)
|
305 |
votes = pdfposter.retrieve_deputy_data()
|
|
|
317 |
|
318 |
pdfposter = PDFPoster(deputy_name)
|
319 |
pdfposter.retrieve_deputy_data()
|
320 |
+
pdf_buffer = pdfposter.generate_poster(vote_list, message_1, message_2)
|
321 |
pdf_path = f"/data/{deputy_name}.pdf"
|
322 |
with open(pdf_path, "wb") as f:
|
323 |
f.write(pdf_buffer.getvalue())
|