PC Magazine: “Stanza is the best e-book reader for the iPhone, and my favorite.”
21 Cool iPhone Apps - Stanza

How do you combine HTML files to make a book (with chapters)

The titles of the post says it all. I am on Mac OS X and would like to combine HTML files to make a book. I can do this manually with GoLive or various HTML editors, but that is tedious and time consuming.

Stanza appears to be able to open one file at a time... would be great to open a whole lot of them, put them in the order I want, and then have the book be assembled.

Thanks!

Let's bring it back

OK I am the person who started this thread and honestly got lost in the follow up exchanges. I can't really get calibre to work (i never really could get it to work). i would think this is such a simple thing - how does one easily combine/join HTML files on a Mac? I've searched and searched for such a utility and to date no luck. Thus far I've been doing this manually in go live or with word and let me tell you, it's terrible and time consuming.

once the html files are assembled, then it can be opened in stanza or calibre, etc. and should be fine.

any help is appreciated!

Calibre's html2epub does just that

html2epub is a command-line tool that comes with Calibre which "Convert a HTML file to an EPUB ebook. Recursively follows links in the HTML file."

To use it, open a Terminal, cd into the directory where your HTML files reside and issue something like the following command:

$ html2epub -o mybook.epub index.html

While my experience with the GUI of Calibre has not been so great, which kept crashing on me, the command-line tool(s) that come with Calibre just does what it says. You can find the user manual of html2epub at:

http://calibre.kovidgoyal.net/user_manual/cli/html2epub.html

or just type html2epub.

I don't use a Mac but I'm

I don't use a Mac but I'm guessing the how-to would be the same. I finally figured out how this works using Calibre. I was using absolute links and I needed to use relative links to make it work.

1. Save the HTML pages to your PC
2. Using a notepad or something similar application, create a file in this format and save it as .TXT in the same folder as the downloaded html files. (Space added after < to avoid creating link - remove the spaces in actual file)

< html>
< body>
< h1>Table of Contents
< p style="text-indent:0pt">
< a href="./filename1.html">Part 1
< a href="./filename2.html">Part 2
< a href="/./filename3.html">Part 3
< /p>
< /body>
< /html>

3. Change the .TXT extension to .HTML
4. Drag into Calibre
5. Convert to EPUB and test in the viewer
6. Move to Iphone using either calibre server or open the file in Stanza Desktop and transfer that way.

I haven't tested this on the Iphone yet but the links are now working in the Calibre Viewer so it should work in Iphone Stanza as well.

Thanks!

Hi --- thanks for the advice. I tried out the making of a TOC with HTML links to the individual files and compiling with Calibre. This worked. Although I am no computer newbie, I'm also not one who does much command line stuff - regardless -- all the advice was appreciated.

FYI I downloaded the kindle app for the iphone. It doesn't even compare to Stanza. Great work. You're the standard by which all others are measured.

Emily's picture

Did you try zipping up all

Did you try zipping up all the files into one big .zip file and then opening .zip file in Stanza Desktop? This ought to work, though as I mentioned, the chapters might not be in the right order.

Another thing you could do is just concatenate all the files together using Unix commands rather than using Word. It's actually not hard, so let me try to explain. I will probably not do a good job, but it's worth a try:

1. Use the Finder to go to /Users/
2. In that directory, create a folder called MyBook and put all the html files that make up your book in that folder.
3. Launch Terminal.
4. Type the following command at the prompt.

cd MyBook

5. Now, type the following command. Where I have written Chapter1.html, substitute the file name of the html file that corresponds to the first chapter of the book:

cat Chapter1.html > myBook.html

6. Now type the following command, where Chapter2.html is the file name of the html file that has the second chapter of your book:

cat Chapter2.html >> myBook.html

7. Continue, just like that for the rest of the chapters:

cat Chapter3.html >> myBook.html
cat Chapter4.html >> myBook.html
etc.

8. You should now have a file called myBook.html. Open that file in Stanza Desktop.

format support

most of my books that are in .chm format. will stanza support this format soon?

thanks!

Emily's picture

We don't have any plans at

We don't have any plans at this time to support the chm file format.

Emily's picture

Try zipping up all the files

Try zipping up all the files into one big .zip file. Then open that .zip file in Stanza Desktop. The only problem with the approach is that the chapters might end up being in the wrong order, depending on how your zip utility decides to zip the files.

You might also want to see if Calibre can do exactly what you want:

http://calibre.kovidgoyal.net/

I use Calibre all the time

I use Calibre all the time and have already tried sending EPUB files created in Calibre using the zipped html method and it doesn't work. The hyperlinks (table of contents) don't carry over and I end up with a 1 page file. I use these files on my Sony 505 and they work fine.

Earlier this evening, I happen to ask about the problem on the mobileread forums and kovidgoyal, the creator of Calibre said if the hyperlinks don't work, it's a Stanza issue, not a Calibre issue.

I'm still digging around for a work around or different Iphone reader that might work.

Emily's picture

I am assuming you are talking

I am assuming you are talking about Stanza iPhone. Hyperlinks do work in Stanza iPhone, and should be working for you. I am assuming you know that you need to hold down on the hyperlink, rather than simply tap on it, right? Would you be willing to give us the output file so we can have a look?

If you are instead talking about Stanza Desktop, that makes sense. Stanza Desktop does not display hyperlinks. However, if you create an ePub with Calibre, and then use Stanza Desktop to transfer the file to Stanza iPhone, the hyperlinks should work in Stanza iPhone, even if you don't see them in Stanza Desktop.

You said, "If you are instead

You said, "If you are instead talking about Stanza Desktop, that makes sense. Stanza Desktop does not display hyperlinks. However, if you create an ePub with Calibre, and then use Stanza Desktop to transfer the file to Stanza iPhone, the hyperlinks should work in Stanza iPhone, even if you don't see them in Stanza Desktop".

I tested Stanza Desktop by opening an EPUB file I created using Calibre then downloading it to the Iphone. I can see the links but I get an error if I try to open any of them. I've opened a ticket with kovid and hopefully, he will be able to solve the problem. The error on thr Iphone reads, "Invalid Link. Sorry, the link is invalid or leads to an external file."

Did I misunderstand your statement above or am I trying to do this wrong?

Emily's picture

That is what I meant. If the

That is what I meant. If the links are correctly done by Calibre, then there is no reason why they should not work when you view the ePub file in Stanza iPhone.

In your post from yesterday (right below this one), you said that the links in the Calibre-generated ePub file do not work, no matter what app you use, isn't that right? If so, this is a bug in Calibre, and I am sure kovidgoyal will be fixing it soon. (By the way, what applications did you try, other than Stanza?)

You also might want to run your ePub through the ePub validity checker, like the one at bookworm.oreilly.com. There is a known bug in the ePub validity checker that doesn't pick up certain errors having to do with table of contents, so you might not get an error even when there is one, but it's worth a try.

I'll start with the premise

I'll start with the premise that one knows how to write the file that is needed to turn multiple html files into one single file (story).

For MOBI or LRF, I download the html pages to my PC, create the file that is needed for Calibre and convert the file. The result is a single file with a table of contents (hyperlinks) - one book. Perfect. Not so with EPUB. I tried the EPUB validity checker and it errors on the local links, passes on Web links.

I tested EPUB again but this time, instead of downloading the html pages to my PC then using hyperlinks pointing to the local files, I tried using the URL from the original site and converting the file in Calibre. I then opened the file on my Iphone. When I clicked a link, Safari opened and pulled up the original Web page - no EPUB book was created. It was worth a try since I already know the local links don't work :-)

The issue appears to be with Calibre since the EPUB file links don't even work in the Calibre viewer. I'll let you know if or when there is a way to make this work!

Yes, Iphone... OK, I tested

Yes, Iphone...
OK, I tested further today and figured out that this is an issue with the EPUB file being created in Calibre. If I use LRF or MOBI as the output format, the hyperlinks work but if I use EPUB, they don't work at all, regardless of the app I use to open the file. Nothing to do with Stanza.

I'll go back to kovidgoyal and check into this. Someone else on the mobilread forum said he has no problem with EPUB. If it's just me then I'll figure out the problem since the multiple html into one book is fantastic. I can explain how to do this if anyone needs help.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.