Learn Python: post #108 — TG.ME

How to convert image to pdf in Python # Python3 program to convert image to pfd # using img2pdf library   # importing necessary libraries import img2pdf from PIL import Image import os   # storing image path img_path = "Input.png"   # storing pdf path pdf_path = "file_pdf.pdf"   # opening image image = Image.open(img_path)   # converting into chunks using img2pdf pdf_bytes = img2pdf.convert(image.filename)   # opening or creating pdf file file = open(pdf_path, "wb")   # writing pdf files with chunks file.write(pdf_bytes)   # closing image file image.close()   # closing pdf file file.close()   # output print("Successfully made pdf file") pip3 install pillow && pip3 install img2pdf تحويل صورة إلى ملف PDF باستخدام #Python @SuDevelopers @NoPython ♻️فضلا شارك هذا المنشور مع الاصدقاء والمهتمين♻️

👍8❤3
April 9, 2025 4.9K 10