Reading .pdf files comfortably on Kindle

In this post we see a method to view PDF files into a Kindle or other e-reader devices almost as comfortably as we would a more native format like .mobi or .epub. We explain how to use a piece of software called k2pdfopt in order to achieve that. Steps to install this software along with the Google Tesseract OCR engine are included. Furthermore an example usage scenario along with explanations of the parameters utilized by the software are given so that the user can learn how to use it in order to be able to read his PDF files in his e-reader device comfortably.

Lately I have been playing around with the idea of having an e-book reader. I read so many papers, academic books and novels that it would be a real big savior if I could keep some of them in a gadget that is made just for that. As far as the academic papers are concerned, it could save whole forests just because I wouldn’t have to actually print them on paper in order to read them.

Just as I was thinking about this a certain special somebody gave me the following kindle paper-white as a gift, one of the best and most appropriately targeted gifts I have ever received.

A kindle paperwhite device

Reading e-books using a kindle paperwhite is a breeze and an amazing experience. You can read them under any possible lighting conditions and without having to worry at all about the battery running out. Moreover they fit nicely to the screen of your e-reader and you can adjust the font-size to fit your preferred reading style. PDF files are, unfortunately, not that easy to work with from the perspective of an e-reader.

All the academic papers that I know and am interested in reading come in .pdf format. As I said above the .pdf format is really not the most suitable format for an e-reader. From my experience in kindle paperwhite you have the ability to pinch-zoom but it is so difficult and so hard to achieve a desired zoom that in my opinion it just isn’t worth it. There is always the possibility to use popular software like Calibre to convert your documents from .pdf to a more e-reader friendly format but in my experience the end result is not very good and does not constitute a pleasant reading experience.

After a little research around the web I came across this very informative post that did an analysis of all the options we have as far as reading .pdfs from an e-reader is concerned. Here I would like to basically extend my succesfull experience of using the last software he presents in his post, the k2pdfopt.

k2pdfopt is a command line tool that allows you to turn any .pdf into yet another .pdf that is adjusted and resized exactly for the dimensions of your particular e-reader device. It also has the ability to use OCR libraries to recognize the text of the .pdf and make it possible for you to take notes on it, highlight the text or even use the dictionary on some words of the PDF text. Let’s see the steps that you have to follow to make it work for you.

  • Download k2pfopt: First of all go and download k2pdfopt from the download link and choose your system. It is available for Windows, Linux and MacOsX!
  • Download Tesseract OCR: You can omit this step if you don’t want to be able to highlight text, recognize it and use the dictionary but why wouldn’t you? It’s very simple to accomplish. Go to the Tesseract download page and choose the appropriate language data file for your language. For example in my case and at the time of writing of this post (the 3.02 version of tesseract was the latest) I downloaded “tesseract-ocr-3.02.eng.tar.gz” for the English language data and “tesseract-ocr-3.02.jpn.tar.gz” for the japanese OCR data.
  • Installing Tesseract OCR: Put all the language data inside a directory in your computer. Let’s assume that this directory is Path/To/Tesseract/. Now depending on your Operating system you will have to create and set an environment variable called TESSDATA_PREFIX. Set this variable to the value of the directory you keep the downloaded data, in our case Path/To/Tesseract/ and you will be set to go. Remember that in Windows you may need to restart your system after setting the environment variable. For a more in-depth analysis of how to do this check the k2pdfopt OCR page and the Tesseract Read-me site.

After these steps are done you are ready to use the software to make those nice .pdfs nicely viewable in your kindle or any other e-reader device you may have. All you have to do is open a terminal window and call the k2pdfopt program with the right parameters. Look below for an example invocation of the program

k2pdfopt document.pdf -ocr -ocrlang eng -dev kpw -bp -f2p -1

Let us analyze the call to the program a bit here.

  • document.pdf: This is the input .pdf file we would like to convert for comfortable reading in the e-reader device.
  • -ocr:This option enables Optical Character Recognition (OCR) with the Tesseract engine that we downloaded above.
  • -ocrlang eng: This option selects the OCR language that Tesseract will use. If for example you had a Japanese text you would have to use -ocrlang jpn and the program would perform OCR on the Japanese text. It works, I have tried it.
  • -dev kpw: This option selects the resolution of the device that we would like the new .pdf to be optimized for. In the example above I used the value kpw which stands for Kindle Paper White but the program offers many other precomputed values for various e-reader devices such as k2 for Kindle 2 and nookst for Nook Simple Touch. In the worst case you can specify the dimensions of your e-reader manually via the -w and -h options.
  • -bp: This is a very important option that instructs the program to force break the pages of the output when the input document has a page break. You need this option turned on unless you like having the output document having page breaks in random places.
  • -f2p <val>: Fit-to-page option (Taken directly from the program’s documentation). The quantity controls fitting tall or small contiguous objects (like figures or photographs) to the device screen. Normally these are fit to the width of the device, but if they are too small or too tall, then if =10, for example, they are allowed to be 10% wider (if too small) or narrower (if too tall) than the screen in order to fit better. Use -1 to fit the object no matter what. Use -2 as a special case–all “red-boxed” regions (see -sm option) are placed one per page. Default is -f2p 0. See also -jf. Note: -f2p -2 will automatically also set -vb -2 to exactly preserve the spacing in the red-boxed region. If you want to compress the vertical spacing in the red-boxed region, use -f2p -2 -vb -1.

After we run this command we will get another pdf file perfectly formatted and OCRed for our e-reader device. It will have exactly the same name as the input document only with a _k2opt suffix appended to it. All you have to do is transfer it to your e-reader and enjoy reading and learning.

I hope this post comes of use to some of you in the same position as me, trying to figure out a way to utilize your kindle/e-reader to make your research and reading activities easier. If you have any comments, suggested feedback or questions do not hesitate to leave a comment below.

LED Sign Tutorial

In this post I present a detailed tutorial on creating an LED signboard. I do my best to explain how to calculate the resistances needed depending on your LEDs and how to solder them once you acquire them. Many pictures are included to make the tutorial more understandable.

After coming to Japan my life has been turned upside down more times and in more ways than I want to admit. Finally after 6 months here I found the time to resume electronics projects. Of course being in another country and not having touched a soldering iron for more than a year added some complications to the whole undertaking.

Determined to resume working with electronics projects I went around Akihabara a few times and returned with all the necessary equipment and quite a few thousand yen less in my wallet. To test the new equipment and to let my hands remember soldering again I set out to create an easy project. In my dormitory some people have signs out of their doors with their names or something representing them as a person. I did not. That needed fixing. And what better way to fix this than an LED sign hanging out of the room’s door? With the background story done, let’s go on to how to create the sign

First of all you need to determine the text/shape that your LEDs will form. After you have done that, draw it on paper and how it would go on a circuitboard (I used a stripboard) and roughly calculate the number of LEDS that will be needed. Once you have that number and you have determined the colours that you will use, visit any of the usual LED calculation tutorials. By giving it the number of LEDs, the voltage of your power source, the voltage drop of each individual LED and the current rating of each LED it can give you the optimal way to connect the LEDs and also the amount of resistance needed. This can save you from a lot of calculations by hand. In the picture below you can see the result of the query in my case.

Led calculator

Continuing if you don’t have them you can now buy the required number of LEDs and resistances to match your power source. For the current example I will write レフいる(need Japanese encoding to read it), which basically means Lef is here/at home. Speaking from experience, I would suggest actually checking each and every one of your LEDs before actually using them, let alone soldering them anywhere. It would be annoying to discover than an LED is defective after you have soldered it on the circuit. Depending on the color and manufacturer of your LED (exact values can be found in the sites I linked above) arrange a small testing circuit on a breadboard and test the LEDs like you can see below.

LED Testing

As I mentioned above I had no tools here in Japan so I had to gradually remember everything that would be needed. This caused the absence of some very essential things I needed such as a free hand tool. Not having one, meant that a contraption had to be made to temporarily hold the circuit. Necessity is the mother of invention as they say.

Funny free hand tool

Of course this was only temporary especially since soldering gun and plastic cloth pins don’t go well together. So a trip to Akihabara later I had a normal free hand tool and was ready to work with it.
Free hand tool You can see that it basically is a mess behind the stripboard due to all the LEDs terminals. But there is no need to worry, it’s easy to organize as we will soon see.

The led terminals mess

Now let’s take a look back at the diagram so kindly made for us by the LED calculation websites. As you can see in my case what I need to do is connect every 4 LED in series. Then each of the quadruples positive terminal should be gathered together to be connected with the power source and each of the negative terminal needs a 10Ohm resistance. The quadruples should all be connected in parallel. As you can understand this means that you can avoid one burned LED turning of the whole sign. Instead if something happens to an LED then it will only affect the quadruple it belongs to. You can see an example of the first 2 quadruples connection for my case in the picture below. Make sure that you connect the LEDs properly taking care to differentiate between anodes and cathodes properly.

Circuit soldering guide

Continuing in a similar way just connect all your LEDs according to the calculator’s results until all of them are connected. Make it easy to differentiate between the terminals of your LED groups since later you will need to connect them all together and link to the power source.

The sign soldering process

Now the only thing that remains is to connect all the LED groups. In my case it easy to differentiate them since as you see from the pictures I made sure that the negative terminals are the ones with the resistances soldered on them and the positive ones are the only non-cut LED terminals. Now how you will connect them depends entirely on you. I chose a more ghetto way and I do know that this is by far not the best way to connect them but it’s sufficient enough for this project.

Final connnections

That was it! It was easy right? All you need to do now is connect the positive terminal of the LED groups to the battery and the negative to ground. Do not forget to add a switch in between since you will need a way to power it on and off.

For me this project served its purposes and I got reacquainted with soldering after a long time. Feels absolutely great. Of course depending on the place where you intend to use it you should figure out a way to hang/stick/attach it on a surface. Since in my case it’s a door sign I used some twine and hang it outside my door.

Sign hanging from the door

Some of the LEDs seem to light up a little less than the others due to the angle the photo got taken from. Normally they all light up the same but depending on the battery’s level some may become less powerfull as time passes and due to the resistances if the battery level is low enough the whole sign will turn off. That’s when you know you gotta change the battery. Here is a close up of the sign.

Sign closeup

As I mentioned above due to the difference of angle some LEDs seem to light up a lot less than the others. But in this picture there is one burned LED due to a mistake I made in the soldering. I will correct it later when I find the time for it. For now the sign has accomplished all the purposes I meant it for.

More importantly I hope that the sign along with the tutorial helped you in your endeavour of making an LED sign yourself. You can make any kind of sign with any LED color following this tutorial. I could have used blue LEDs which are a lot more powerfull but also equally more expensive. I did not want to spend more money than needed for this sign hence I went with red and yellow. The color you choose depends entirely on your own design. I wish luck to all of you who try to make an LED sign and if you have any questions about this tutorial or any sugestions/corrections feel free to email me at lefteris *at*