Question

How to programmatically convert HTML to epub?

Can I do this conversion with any programming language or library?

 45  51963  45
1 Jan 1970

Solution

 62

The short answer is yes, it can be done in any programming language.

Basic steps:

  1. Convert your HTML to XHTML (+ CSS). This can be done in your program or through an XSLT file.
  2. Copy your files (XHTML, CSS, any images and fonts) into a directory structure that follows the format.
  3. Zip the directory structure up and name the archive with a ".epub" extension.

Some web sites to help you get started:

June 2015 Note: The epubcheck validator has moved from google code to GitHub; note the new URL.

2010-12-09

Solution

 16

Calibre supports a wide variety of input formats, including HTML, and a wide variety of output formats, including EPUB, but it's not "a programming language or library". Are there specific reasons you desire a programming-based approach rather than a free-standing tool? If so, maybe Python and ebookmaker.py, for example, could help you.

2010-08-11