In this modern era, everything is digitized. The E-Books have became mainstream. EBooks are available in various formats such as PDF, EPUB, MOBI, AZW3 and IBA Etc. Most e-Book readers does support almost all formats. However, some e-Book reader may not support a specific format. For example, ASW3 files will only be viewed by Amazon Kindle. In such cases, we need to convert the e-Books from one format to another supported format. In this quick tutorial, we will see how to easily convert EBooks from PDF to EPUB format (and vice versa) in Linux.
There are many online and offline applications exists to convert an EBook from one format to another. For the purpose of this tutorial, we will be using Calibre e-book suite, which let us to convert ebooks from both CLI and via GUI.
Table of Contents
Install Calibre in Linux
Calibre is a free and open source e-Book software suite for reading, editing, organizing, creating and converting e-books, as well as syncing e-Books with other e-Book readers.
Calibre runs on all major computer operating systems such as Linux, macOS and Windows, and both console and graphical versions are available.
To install Calibre in Arch Linux and its variants such as EndeavourOS and Manjaro Linux, run:
$ sudo pacman -S calibre
Install Calibre in Debian, Ubuntu, Pop OS:
$ sudo apt install calibre
Fedora:
$ sudo dnf install calibre
openSUSE:
$ sudo zypper install calibre
Now, let us see the commandline way to convert PDF files to EPUB format.
Convert PDF Files To EPUB Format From Commandline Using Calibre
Calibre suite has a commandline tool called "ebook-convert" to do ebook conversion between different formats.
To convert an eBook from PDF to EPUB format, simply run:
$ ebook-convert file.pdf file.epub --enable-heuristics
This command will convert the given PDF document to .epub
format and save the output file in the current directory.
Sample output:
Conversion options changed from defaults: enable_heuristics: True 1% Converting input to HTML... InputFormatPlugin: PDF Input running on /home/ostechnix/file.pdf [...] Splitting markup on page breaks and flow limits, if any... Looking for large trees in index.html... No large trees found Split into 84 parts Generating default cover EPUB output written to /home/ostechnix/file.epub Output saved to /home/ostechnix/file.epub
You can now view the EPUB file using any EPUB viewer applications. Calibre is known to support almost all eBook formats.
Here, the --enable-heuristics
option is used to enable heuristic processing, which modifies the document text and structure using common patterns. When this option is passed, Calibre will scan your Ebooks for common patterns and automatically fix them. This option is disabled by default.
Usually, enabling heuristic processing improves the quality. Just in case, if the output file doesn't turn out as you expected, simply remove this option and try again like below.
$ ebook-convert file.pdf file.epub
You can also disable individual heuristic processing actions with the --disable-*
options.
Example:
$ ebook-convert file.pdf file.epub --enable-heuristics --disable-italicize-common-cases
The ebook-convert accepts a lot of arguments to fine tune the Ebook conversion task. To learn all supported options, please have a look at the official documentation of ebook-convert command.
Some of you prefer the graphical method over CLI way. If so, Calibre has a graphical version as well.
Ebook Conversion Using Calibre Graphical Interface
Launch Calibre application from Menu or Application launcher. Click "Add books" button from menu bar and choose the PDF file from your local drive.
After adding the PDF files, Click "Convert books" option.
In the next window, choose the output format. I am going to convert PDF file to EPUB format, so I chose "EPUB" from the drop-down list.
Calibre allows you to do a lot of customization to the output file. There are several sections presented on the left pane of Calibre interface. Each section allows you to change various settings and fine tune the conversion process.
Using Calibre, you can do the following customization:
- Edit and change metadata of the Ebook (E.g. Title, author name, publisher name, tags etc.),
- Change look and feel (E.g. font type, size, text alignment, layout, styling),
- Enable heuristic processing,
- Page setup (E.g. Adjust margins),
- Add Table of contents,
- Search and replace texts,
- Add/Change cover image and more.
Choose the respective section from the left pane and change the given parameters in that section as per your requirement. Once you made all customization, click "OK" to continue.
After the conversion is done, the converted file is saved in the "Calibre Library" folder, which is usually found in the $HOME
directory of your Linux system. Each file is stored in a separate folder with author's name.
You can upload the converted file to the ebook reader and or open it via a ebook viewer application and start using it.
Conclusion
In this guide, we learned how to convert Ebooks from PDF format to EPUB using Calibre software suite. Since Calibre is available as both CLI and GUI version, you can do Ebook conversion from the Terminal or GUI window.