ebook-convert
Convert ebook formats
TLDR
Convert an e-book into another format
Convert Markdown or HTML to e-book with TOC, title and author
SYNOPSIS
ebook-convert input_file output_file [options]
PARAMETERS
input_file
The path to the source e-book file.
output_file
The path for the converted e-book file. The extension typically determines the output format.
--authors "Names"
Set the authors for the output book, e.g., "John Doe & Jane Smith".
--title "Title"
Set the title for the output book.
--output-profile profile_name
Specify the output device profile (e.g., kindle, kobo).
--enable-heuristics
Enable heuristic processing to improve conversion results by fixing common issues.
--no-default-epub-cover
Do not generate a default cover for EPUB output if one is not specified.
--input-encoding encoding
Specify the character encoding of the input document (e.g., utf-8).
--output-encoding encoding
Specify the character encoding for the output document.
--extra-css path_to_css_file
Path to an additional CSS file to apply during conversion, overriding or extending existing styles.
--chapter xpath_expression
An XPath expression to identify chapters in the input document for TOC generation.
--page-breaks-before xpath_expression
An XPath expression to identify locations where new page breaks should be inserted.
--verbose
Print more detailed information during the conversion process, useful for debugging.
--help
Show a help message listing all available options and exit.
--version
Show program's version number and exit.
DESCRIPTION
ebook-convert is a powerful command-line tool that is a core component of the popular open-source Calibre e-book management suite. It is designed for high-quality, flexible conversion between a vast array of e-book formats.
Users can convert from formats like EPUB, MOBI, AZW3, PDF, DOCX, HTML, RTF, and TXT, to target formats such as EPUB, MOBI, AZW3, PDF, TXT, HTMLZ, OEB, and many others. The command offers extensive control over the conversion process through numerous options, allowing customization of metadata, table of contents generation, styling, font embedding, image handling, and more. It is an indispensable tool for automating e-book workflows or for users who prefer command-line operations.
CAVEATS
PDF output quality can be highly variable and difficult to control precisely due to the complex nature of PDF rendering and the inherent lossiness of converting from a fixed-layout format.
Conversion of complex layouts, especially from PDF inputs, might not always yield perfect results and may require significant fine-tuning of options.
The extensive number of options can make the command-line arguments very long and complex for advanced customizations, requiring careful attention to syntax and escaping characters.
BATCH PROCESSING
While ebook-convert processes one file at a time, its command-line nature makes it ideal for batch processing. It can be easily integrated into shell scripts or other automation tools to convert entire directories of e-books efficiently, making it a powerful tool for large collections.
ADVANCED CUSTOMIZATION WITH CSS AND XPATH
The command offers advanced customization capabilities through the use of external CSS files for precise styling control and XPath expressions for fine-grained manipulation of document structure, such as identifying chapters, page breaks, or specific HTML elements for processing during conversion.
HISTORY
ebook-convert is a core component of the Calibre e-book management software, which was first released in October 2006. It originated from a Python script written by Kovid Goyal to convert LRF (Sony Reader) format files to provide content for his Sony Reader device. As Calibre evolved into a comprehensive e-book ecosystem, ebook-convert became its powerful and flexible conversion engine, continually updated to support an ever-growing array of e-book formats and sophisticated conversion features.