Python Projects & Free Books
38K subscribers
604 photos
93 files
305 links
Python Interview Projects & Free Courses

Admin: @Coderfun
Download Telegram
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
👍29👎1
Python Libraries and Frameworks
👍11
Mastering Python Networking

📓 Book
👍11👎1
Python_Tips_and_Tricks_A_Collection_of_100_Basic_&_Intermediate.pdf
3 MB
Python Tips and Tricks
Benjamin Bennett Alexander, 2022
👍15
pip install PyPDF2
pip install pyttsx3


```python
import PyPDF2
import pyttsx3
# Read the pdf by specifying the path in your computer
pdfReader = PyPDF2.PdfFileReader(open('clcoding.pdf', 'rb'))
# Get the handle to speaker
speaker = pyttsx3.init()
# split the pages and read one by one
for page_num in range(pdfReader.numPages):
text = pdfReader.getPage(page_num).extractText()
speaker.say(text)
speaker.runAndWait()
# stop the speaker after completion
speaker.stop()
# save the audiobook at specified path
engine.save_to_file(text, 'E:\audio.mp3')
engine.runAndWait()`

🔅 Create an Audiobook in Python
👍57👎1