Read Manning Books on an HD Ebook Reader

Make Manning Ebook Code Examples Readable on a tolino HD Reader

I really appreciate Ebooks from Manning for their documentation of open source projects. Their Early Access Program makes new titles covering emerging technologies rather accessible. Unfortunately, code samples and many images and diagrams are hardly readable on my tolino HD ebook reader. Reason is that images in the ebooks are rendered with 590 pixels width while my reader has a screen resolution of 1072 x 1448. So an original page looks like this:

Original size screenshot from Spark in Action

I definitively cannot read the code. And in contrast to normal text, it cannot be scaled up because it is an image. To make my books useful I have to upscale the images.l Fortunately epub uses html and css internally to format the book, and calibre ebook management software has powerful editing options to modify my ebooks. After some work, upscaling images to 90% screen width, the same code sample becomes a bit blurred but readable:

Same screenshot after upscaling

Here is how I did it:

  1. Make a copy of your .epub file (just for safety).
  2. Load it into calibre. (I assume you know basically how to use calibre. Else there are tutorials out there.)
  3. Now you can edit your ebook. I will demonstrate this with the above mentioned „Spark in Action“ ebook.
  4. On the left side of the editor you can find the stylesheet.css file with all central styling information for your book. Open it for editing with a double click.

    This is the style that is used for mostly all images in the book. If we change the width attribute to 90% (or 99% if you like), all the images scale up to the width of your readers screen.
  5. In a perfect world we would be done. But there are images that should not scale up to full width, e.g. little arrows that symbolize wrapped lines or bullet numbers that explain marks in code samples. In some books even the title images would get messed up. So we have to do somewhat more. Lets start with copying style .calibre2 and call it .callibre2x.

    So we get different styles for images to scale and others to stay in their original size. We now have to change the class attribute for all <img …> tags that should stay unscaled.
  6. Fortunately, calibre comes with great regular expression support. If you never worked with regular expressions, try it with my explanations. We can change lots of lines in our book with a few commands. So open the search/replace fields at the bottom of the editor window with Ctrl+F (or from the menu bar). Let’s start with replacing all class attributes of the enter arrow image named „enter.jpg“.You should enable regular expression search with Regex from the dropdown and search thru all text files. Give it a try by clicking on Find (right bottom) and admire the big blurred arrow in the preview window at the right. Clicking replace will change its size to original. You will hardly find the image in the preview now, small as it is. Click Find again to go to the next arrow and then Replace all to change all these images.
  7. Next step is replacing all numbered bullets. The search string differs a bit in my books. In some, it is src="num-(..).jpg" class="calibre2" ,
    in others it has an additional alt=““ attribute
    src="num-(..).jpg" alt="" class="calibre2" . Use the first one for Sparc in Action and  search for src="num-  to find out what it is like in your book.
    The (..) part stands for two digits that will be used in the replace string src="num-\1.jpg" class="calibre2x" . \1 stands for the characters matched inside the brackets.
  8. Let’s get to the final. There still are a few images like logos etc. Look for  src="common(.*).jpg" class="calibre2"  and change it to src="common\1.jpg" class="calibre2" . Here I use (.*) which matches any number of characters in that position.
  9. That’s it! Just save your edited ebook, load it to your reader and enjoy readable code samples. If any images are still oversized and blurred, repeat the process by identifying the image file names and changing the style class to calibre2x.

Hope this helps and you are not too much puzzled by the German button captions in my screenshots. And also I hope that Manning changes their ebook production setting to also serve their customers with modern HD ebook readers without this kind of hussle.

Georg Beier

Autor: Georg Beier

Seit mehr als 20 Jahren lehre ich Software Engineering und Programmierung als Professor an Fachhochschulen, zuerst in Mannheim und jetzt in Zwickau. Vorher habe ich, nach meiner Promotion in Physik an der TU München, acht Jahre in Münchner IT-Firmen gearbeitet. Mein besonderes fachliches Interesse gilt der Analyse komplexer Systeme, ihrer Modellierung und Implementierung in Software.
Weiterhin fasziniert mich die Arbeit in internationalen Projekten. Daher leite ich einige DAAD-Projekte meiner Hochschule mit Partneruniversitäten in Kirgisistan und Georgien.
Privat segle ich gern im Urlaub meine Topper Jolle. Wenn mir bei meinen Aufenthalten in Kirgisistan ein wenig Zeit bleibt, reite oder wandere ich mit Begeisterung in der großartigen Hochgebirgswelt.

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert.