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)
Last edited by lonly; 06-26-2025 at 03:56 PM.
|