Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to programmatically convert HTML to epub? [closed]

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

like image 947
Juanjo Conti Avatar asked Aug 11 '10 02:08

Juanjo Conti


People also ask

Can HTML be converted to EPUB?

How to Convert HTML to EPUB? Click the “Choose Files” button to select your HTML files. Click the “Convert to EPUB” button to start the conversion.


2 Answers

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:

  • A good tutorial for what's in an epub file (and how to create one yourself) can be found here: http://www.jedisaber.com/eBooks/Introduction.shtml. I used this to get started myself.
  • Specs for the .epub standard are here: http://www.idpf.org/
  • A validator for .epubs can be downloaded from here: https://github.com/IDPF/epubcheck

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

like image 64
eb1 Avatar answered Sep 28 '22 23:09

eb1


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.

like image 30
Alex Martelli Avatar answered Sep 29 '22 00:09

Alex Martelli