Skip to content

Instantly share code, notes, and snippets.

@0riginaln0
Created July 18, 2025 10:01
Show Gist options
  • Select an option

  • Save 0riginaln0/711209393cfdf1038faee3a52015dcf0 to your computer and use it in GitHub Desktop.

Select an option

Save 0riginaln0/711209393cfdf1038faee3a52015dcf0 to your computer and use it in GitHub Desktop.
create pdf from images
# pip install fpdf
from fpdf import FPDF
# List of JPEG image filenames
image_filenames = [
"1.jpeg",
"2.jpeg",
"3.jpeg",
"4.jpeg",
] # Replace with your image filenames
pdf = FPDF()
for image_filename in image_filenames:
pdf.add_page()
# Set the image to fit the page
pdf.image(image_filename, 0, 0, 210, 297) # 210x297 mm is the size of an A4 page
# Save the PDF to a file
pdf.output("out.pdf")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment