The short answer is yes, it can be done in any programming language.
Basic steps:
- Convert your HTML to XHTML (+ CSS). This can be done in your program or through an XSLT file.
- Copy your files (XHTML, CSS, any images and fonts) into a directory structure that follows the format.
- 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.