1. Usually the error messages from the :open() method are too long (except for crereader files) and won't be shown. So, I extract the first 30 bytes from the error message (if there is one) and show that. But if there is no error message then just display the generic "Error opening document ". Otherwise, as was currently the case, the error message is present but is too long and so we get absolutely nothing, not even a generic one. But in the Debug output we can show the entire error message as there is no restriction on the length. 2. Use showInfoMsgWithDelay() instead of InfoMessage:show() followed by util.sleep(). 3. Remove the dependency on keys.lua. This was needed when we were detecting emulation by comparing the physical value of some KEY_ but now we use util.isEmulated() so there is no need for it anymore.
KindlePDFViewer
This is a PDF viewer application, created for usage on the Kindle e-ink reader. It is currently restricted to 4bpp inverse grayscale displays. It's using the muPDF library (see http://mupdf.com/) and its UI is scripted using Lua (see http://www.lua.org/).
The application is licensed under the GPLv3 (see COPYING file).
Building
Follow these steps:
-
fetch thirdparty sources
-
manually fetch all the thirdparty sources:
- install muPDF sources into subfolder "mupdf"
- install muPDF third-party sources (see muPDF homepage) into a new subfolder "mupdf/thirdparty"
- install libDjvuLibre sources into subfolder "djvulibre"
- install CREngine sources into subfolder "kpvcrlib/crengine"
- install LuaJit sources into subfolder "luajit-2.0"
-
automatically fetch thirdparty sources with Makefile:
- make sure you have wget, unzip and git installed
- run
make fetchthirdparty.
-
-
adapt Makefile to your needs
-
run
make thirdparty. This will build MuPDF (plus the libraries it depends on), libDjvuLibre, CREngine and Lua. -
run
make. This will build the kpdfview application
Running
The user interface (or what's there yet) is scripted in Lua. See "reader.lua". It uses the Linux feature to run scripts by using a corresponding line at its start.
So you might just call that script. Note that the script and the kpdfview binary currently must be in the same directory.
You would then just call reader.lua, giving the document file path, or any directory path, as its first argument. Run reader.lua without arguments to see usage notes. The reader.lua script can also show a file chooser: it will do this when you call it with a directory (instead of a file) as first argument.
Device emulation
The code also features a device emulation. You need SDL headers and library for this. It allows to develop on a standard PC and saves precious development time. It might also compose the most unfriendly desktop PDF reader, depending on your view.
If you are using Ubuntu, simply install libsdl-dev1.2 package.
To build in "emulation mode", you need to run make like this: make clean cleanthirdparty EMULATE_READER=1 make thirdparty kpdfview
And run the emulator like this:
./reader.lua /PATH/TO/PDF.pdf
or:
./reader.lua /ANY/PATH
By default emulation will provide DXG resolution of 824*1200. It can be specified at compile time, this is example for Kindle 3:
EMULATE_READER_W=600 EMULATE_READER_H=800 EMULATE_READER=1 make kpdfview