Is there any command-line software to create e-books from the scratch in Ubuntu?

8,872

Solution 1

A wide variety of documents can be converted to ebook (epub, mobi, ...) using ebook-convert which is part of the calibre package.

For example, as long as input is a supported format, an epub can be created with the command:

ebook-convert  input output.epub

Or, if you use kindles:

ebook-convert  input output.mobi

Some input formats include: LIT, MOBI, AZW, EPUB, AZW3, FB2, DOCX, HTML, PRC, ODT, RTF, PDB, TXT, PDF.

If the input file is a PDF, then one may want to add an option:

ebook-convert --enable-heuristics  input.pdf output.epub

Calibre may be available from your package manager but it often helps to install the latest version which is available here.

Authoring a book

As an alternative to calibre, OpenOffice/LibreOffice offers an extension, Writer2ePub, to claims to be able to create "well formatted, easy readable ePub" files with a single click.

The Writer2ePub extension can be downloaded from here.

Solution 2

The software pandoc ( http://pandoc.org/ ) might come in handy for your needs. It can be installed in Ubuntu by opening a terminal (Alt-Ctrl-T) and typing sudo apt install pandoc.

Pandoc can convert between a variety of different formats, including txt, html, xhtml, doc, docx, odt, epub, fb2, docbook, OPML, LaTeX, pdf, markdown, asciidoc, MediaWiki, Dokuwiki, org-mode, and a variety of others.

It does not appear to support conversion to/from mobi or aw3, but could certainly build an epub file from a variety of different sources. Then if you like the epub file it produces, you could use @John1024 's answer to convert to mobi or kindle format.

By starting with a source file that supports formatting, such as markdown, html, asciidoc, or the like, you can get a nicely-formatted epub output. The pandoc README file gives a nice overview of the command-line options that are available (including options for table of contents, fonts, link styles, margins, etc).

Share:
8,872

Related videos on Youtube

Thiago Rider Augusto
Author by

Thiago Rider Augusto

Updated on September 18, 2022

Comments

  • Thiago Rider Augusto
    Thiago Rider Augusto almost 2 years

    I would like to automate e-book build from remote repositories. A command-line tool would be useful in this case. Is there any software for Ubuntu?

  • Thiago Rider Augusto
    Thiago Rider Augusto almost 8 years
    I don't want to convert, I need a command-line software which can build the e-book from its source.
  • Thiago Rider Augusto
    Thiago Rider Augusto almost 8 years
    It's like a markup language: jedisaber.com/eBooks/formatsource.shtml
  • John1024
    John1024 almost 8 years
    That markup language is a subset of HTML. Calibre works well with HTML.
  • John1024
    John1024 almost 8 years
    @ThiagoRiderAugusto By the way, that is a nice tutorial. It begins with html (part 1) and ends with zipping the files up into an epub (part 3). How close are your sources to the final format?
  • Thiago Rider Augusto
    Thiago Rider Augusto almost 8 years
    Pure text and images... Still thinking how to assemble everything LOL
  • John1024
    John1024 almost 8 years
    OK. You will likely want to add some markup to indicate chapter headings and image locations and such. If you are a perfectionist, that jedisaber tutorial is ideal: it allows you to have total control over the output. If you want some convenience, you may be satisfied with using a word processor or html editor of your choice and then trust in calibre or pandoc to handle the rest. After the conversion, you can edit the ebook with calibre to do some fine tuning.
  • Thiago Rider Augusto
    Thiago Rider Augusto almost 8 years
    Yeap! This could be a good approach! thx!
  • John1024
    John1024 almost 8 years
    Have you used OpenOffice/LibreOffice? Calibre and Pandoc claim to be able to convert their files to epub. Also, there is a Writer2ePub extension that claims to enable OpenOffice/LibreOffice to create epub directly.
  • Stephen Michael Kellat
    Stephen Michael Kellat almost 8 years
    Pandoc does show an example on its site of how to build an EPUB of moderate complexity using it.
  • nilon
    nilon about 4 years
    @StephenMichaelKellat is referring to the how to make an epub with pandoc example.