Created
July 18, 2025 10:01
-
-
Save 0riginaln0/711209393cfdf1038faee3a52015dcf0 to your computer and use it in GitHub Desktop.
create pdf from images
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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