Thread: pdf to epub
View Single Post
Old 06-26-2025, 03:38 PM   #1
lonly
Member
lonly began at the beginning.
 
Posts: 20
Karma: 10
Join Date: Nov 2012
Location: Bellow the Sky
Device: Laptop
pdf to epub

i am trying to convert pdf to epub file using calibre
first i tried calibre gui which is taking hours but cannot convert that pdf to epub then i use python script with calibre ebook-convert.exe and that is converting pdf to epub but missing a lot of setting i am sharing you screenshot of pdf text and converted epub same area.
check attached files (First image is original PDF and second image is converted epub and see text and diagram is broken in epub)

here is my script code

import subprocess
import os

# Path to your input PDF
pdf_path = r"C:\Users\samsam\Downloads\Analysis of Fork.pdf" # <-- Change 'mybook.pdf' to your actual file name

# Output EPUB path (same folder)
epub_path = os.path.splitext(pdf_path)[0] + ".epub"

# Full path to ebook-convert.exe
calibre_convert_exe = r"C:\Program Files\Calibre2\ebook-convert.exe"

# Command to run conversion
command = [
calibre_convert_exe,
pdf_path,
epub_path,
"--disable-font-rescaling",
"--no-default-epub-cover",
"--preserve-cover-aspect-ratio"

]

try:
subprocess.run(command, check=True)
print(f"✅ EPUB created: {epub_path}")
except subprocess.CalledProcessError as e:
print("❌ Conversion failed:", e)
Attached Thumbnails
Click image for larger version

Name:	pdf ss.jpg
Views:	27
Size:	101.6 KB
ID:	216513   Click image for larger version

Name:	epub ss.jpg
Views:	26
Size:	150.9 KB
ID:	216514  

Last edited by lonly; 06-26-2025 at 03:56 PM.
lonly is offline   Reply With Quote