Tuesday, July 27, 2010

how to adjust font in an existing pdf file to fit my sony prs-505 digital reader (a.k.a. e-book reader)

I own a digital reader sony prs-505 (red colour model) bought around 2 years ago from sonystyle.ca.  It is so cruel that even now they still don't sell it in Thailand (or even with Thai ip address).

As with any other digital readers, its screen resolution and size are different and much smaller than ordinary monitors (for computer desktop or laptop).  For my prs-505, it is 175x122x8 mm (6.9" x 4.8" x 0.3") with 600x800 pixels. (source : wikipedia.org)

With these differences, any pdf files that are not generated specifically for prs-505 contain risk of being blurred and consequently impractical for reading.  However, not only the screen size and resolution that matter but also the font being used in pdf file.  One might argue that pdf is a vector format where we can zoom in and out without losing its sharpness.  I completely agree and understand that but, however, prs-505 comes with only 3 levels of zooming which are small, medium and large.  With just these 3 levels, we can't expect prs-505 to be able read all pdf files properly without extra works.

Usually, I use Calibre to collect rss feeds and convert them into epub format which is a format that works on prs-505.  There are lots of predefined news feeds come with Calibre such as bbc, cnn, telegraphs, reader digest, etc.  A good thing about choosing news from the predefined list is that Calibre knows it well so it fetches the data and formats them very properly for prs-505 which is a known target device to Calibre.  As such, I have nothing to concern about reading news with my digital reader.

However, just recently, I ran into a problem when I tried to read a technical textbook downloaded from some website.  It was in pdf format.  Unfortunately, its font and sizes didn't fit prs-505 as you can see from the picture below (notice that the font colour is too light which causes problem to my eyes):



The page layout / size looked perfect while the font didn't.  All texts were blurred.  They become clearer when I zoomed in it but the large zoom level was too big which just broke the page layout and everything.

I decided I had to make some changes to this pdf file.  There were several approaches I tried:
  1. Using Calibre's GUI to convert the imported pdf file into epub by telling it to change font size to be 12pt, 14pt and 16pt.  In the output, the text's font size was really increased which was good.  But, a bigger problem arose.  For some unknown reason, whenever I changed the base font size via Calibre's GUI, each sentence was divided into separate line which made the entire page looked truly ugly.  This method does not work.
  2. Using Adobe Acrobat Professional to change font of existing pdf.  With Touch Up Text Tool, I was able to change font of the pdf to be Tahoma, for example.  I tried it with a paragraph and it just worked.  It looked great on prs-505.  But, alas, there was no way I could change the font of the entire pdf document.  This is just ludicrous.  It is impossible for me to go through page by page to do that.  Failed again.
  3. Using tools to convert pdf into various formats such as plain text, html, png, rtf, ps (postscript), odt, doc, etc... None of them worked.  Each of them yielded different slight problems when it was used with my prs-505.  Some examples are too big of size file, images distorted, wrong font, wrong paragraphs layout, etc.  It just does not work.
  4. Surprisingly, I decided to get back to Calibre.   For some unknown reason, I tried command-line version of Calibre instead of the GUI using the almost exact same option I chose when I used GUI version:

    $ ebook-convert some_file.pdf some_file.epub --base-font-size 14

    Then I transfered this epub file to my prs-505 and the output looked a lot better as you may notice:




    You will also notice some slight bug such as the second paragraph that is combined into the first paragraph.  Hence, it is not a perfect method yet.  I will just have to live with it meanwhile.

     More details of how to use Calibre's command-line tool to convert books can be found here:

    http://calibre-ebook.com/user_manual/cli/ebook-convert.html#ebook-convert

    Isn't it funny that GUI version and command-line version of Calibre yield different result?  I can only guess that it maybe because the GUI somehow has more options than just "--base-font-size" that I am unaware of!

    0 comments:

    Post a Comment