from fpdf import FPDF
from PIL import Image
# Load the generated image
image_path = "/mnt/data/carbon_footprint_poster.png"
# Convert the image to A3 size in mm (A3 = 297 x 420 mm)
a3_width_mm = 297
a3_height_mm = 420
# Create a PDF with A3 size
pdf = FPDF(orientation='P', unit='mm', format='A3')
pdf.add_page()
pdf.image(image_path, x=0, y=0, w=a3_width_mm, h=a3_height_mm)
# Save the PDF
pdf_path = "/mnt/data/Carbon_Footprint_Poster.pdf"
pdf.output(pdf_path)
pdf_path