Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I programatically Kindlize an .HTML or .DOCX or .PDF file (make it Kindle-ready)?

Empirical observation has brought me to the conclusion that when I upload book files to CreateSpace (print books), they are best rendered from .pdf files. Kindle (eBook) format, OTOH, turn out better when provided as a .docx file.

Still they are far from perfect, though. I created a book that contains text only - one font for English, and then a different font, and bolded, for the alternating translated-into-Spanish paragraphs. The paperback version looks fine. Here's how it displays:

enter image description here

The Kindle version of the file, though, is "9X Uglier than a Bag of Butts" (or at least plainer than Nebraska):

enter image description here

As you can see, it has no breaks between paragraphs (besides the line break - big whoop!), and does not retain the bold formatting on the Spanish paragraph - or even the chapter heading formatting! The Kindlizing process apparently sees all text as being equal - no special formatting attempted!

So, since the Kindle rendering process obviously does not work well (it was even worse when giving them the same PDF I provided to create the book file - parts of it were missing from the rendered content for some reason), is there a way I can programmatically (in C#) massage a file (either HTML, DOCX, or PDF) that will allow the rendered Kindle file to look like the paperback (retaining paragraph breaks and bold formatting)?

UPDATE

I downloaded Calibre (tried to, that is), put Google blocked it and said the sky is falling, and Calibre would ruin my browsing experience. Dadburn it, if this is legitimate software, why does Google block it?!?

UPDATE 2

I tried using Firefox to download Calibre but, although there was no err msg, it simply wouldn't download the file. So maybe it is also blocking it, but "silently."

like image 389
B. Clay Shannon-B. Crow Raven Avatar asked Dec 05 '25 04:12

B. Clay Shannon-B. Crow Raven


1 Answers

kindlegen is Amazon's tool for taking input like HTML and transforming it into MOBI files. We've used it in our Rails project with a lot of success in the past, and you can always shell out to the command-line to run it.

Calibre is a third-party tool that takes in a bunch more formats (PDF, EPUB, etc.) and outputs a bunch more formats as well. It's an absolutely legitimate tool that has a command-line interface (ebook-convert) that can be really useful.

For our projects, we weren't able to install Calibre on our CentOS server, so we ended up just using kindlegen and converting HTML files. Actually, to be specific, we took in OPF files with assorted images, html files, toc.ncx files, etc. to create a .mobi file for final publication.

You might want to also look at what fonts are supported on the Kindle and make sure that your fonts and styles are correctly specified. This PDF from Amazon does a pretty good job of describing what CSS is valid.

like image 109
Waynn Lue Avatar answered Dec 06 '25 17:12

Waynn Lue