View Full Version : How can i convert HTML or txt file to EPUB file ?

05-20-2010, 04:18 AM

I worked in vs2005 c++ (MFC,win32).

I need to work on my project to add html or txt file converted to epub formats.

I used Calibre2,but it is too large and can not support c++,so i can not modify that source code .

I do that is difficult...

How can i get some free(or not free) source code for convert html or txt file to EPUB in VS2005 (MFC ,win32) ?


05-20-2010, 08:26 AM
Write it yourself? Transforming of basic html to a basic epub is not that hard. What is it you want to do with your project that isn't covered with Calibre or Sigil.

05-20-2010, 11:13 PM
thanks your reply.

write it myself.

I just started learning ,I do not know what the reference data for convert html or txt file to EPUB.
In html file include:text,picture,video,audio....

You said that is not hard. How can i start this project?


05-21-2010, 05:17 AM
Read a lot about the epub format and create some epub's yourself by hand (I find the jedisaber site to be of great help there). Look at some epub's.

If the html includes video and/or audio, than epub is not the format for you. That is not covered. You can use font's and pictures though.

By the way, you can call parts of Calibre from you project to convert to epub. So, you write some part and call a program of Calibre with your input. That should ease your project.

05-21-2010, 11:42 PM
An ePub file is just a .zip file containing (x)html along with associated images, fonts, and xml files containing metadata and a table of contents. See the Step by Step guide to ePub creation ( for links to learning more about the spec.

I don't know much about C, but I'm sure there are ways to use it to create xml and zip files, and if it can do that, it can create epubs.

05-24-2010, 05:52 PM
If you want to see some epub code in C++, then you should take a look at Sigil (, which is GPL'd and should be fine for your use.

Sigil, of course, is a large editing project. The bits you'll want to examine are in the Exporters directory, which has code showing how to construct the NCX and OPF files you need. As frabjous said, the rest is just zipping up the component files and setting the mimetype (which must not be compresssed).

05-27-2010, 09:49 PM
Read about EPUB ( at wikipedia, which has links to the formal specification. You can find open source XML parsers in C++, as well as zip libraries.

05-28-2010, 10:15 PM
You might try the Inside epub ( blog. It's a series of articles about various components of an epub. It helped me quite a bit.