Tuesday, July 31, 2012

Editing the CSS of EPUB files

I make medical textbooks for a living. Mostly medical. We're getting a lot more history books than we used to. And they're simpler than the medical stuff. They don't move as fast either. Some we've got coming our way don't seem like they're worth printing at all. But we'll want to edit and release them anyway. So, I'm suppose to be looking into making eBooks out of them.

I chose the EPUB format largely because InDesign can export to that format and it's fairly common. I knew that some of the formatting would be lost. A lot, actually. How much kinda depends on what you're reading with. I'm testing primarily with a Sony Reader PRS-300, but I've downloaded a few readers to my Android phone. The readers that would allow me to read books that I didn't buy from them were pretty much all rubbish.

The book we're editing now is designed to go in the leg pocket of Army fatigues. It's a quick reference for common procedures you can expect in field hospitals. It has only one column of text, little art or tables, and lots of bulleted lists. It also has lots of blocks of text that have a shaded background. Those refuse to export. They will in CS6, but I'm still running on CS5.5. But I knew there had to be a way. Lots of people told me to edit the CSS. But how do you do that when you've never seen a CSS file associated with an EPUB anywhere?

An EPUB isn't a document in an of itself. If you open it in a text editor you get nothing. First you have to decompress/unzip it. Then you have two folders and a mimetype file. In the folders are the images, HTML, CSS, XML, OPF, and any fonts that may work in the viewer. So you can open the CSS file in your choice of editor, fix it up, and save it. But simply recompressing/zipping the folders and mimetype won't do it. You have to compress/zip the folders and then add the uncompressed mimetype to the ZIP file. Then change the suffix of the file from ZIP back to EPUB.

I jokingly told my boss that I need to write a book called "Didn't I Mention That?" for all not-so-obvious stuff that we're supposed to know. I mean that's a lovely programming book you have, but how do you create the file in the first place? How do you compile? Those files I need to edit to make that electronics board work, where are they? That said, there's plenty of stuff that I'm assuming you know and don't explain here. Compressing/zipping files. Text editors. How to write CSS. Stuff like that. Those are completely different lessons. But leave a comment about your issue and I'll be happy to point you in the right direction. My eReader is reading my modified EPUBs. If yours isn't, just comment.

No comments: