View Single Post
Old 03-09-2010, 10:26 AM   #1
DairyKnight
Connoisseur
DairyKnight plays well with othersDairyKnight plays well with othersDairyKnight plays well with othersDairyKnight plays well with othersDairyKnight plays well with othersDairyKnight plays well with othersDairyKnight plays well with othersDairyKnight plays well with othersDairyKnight plays well with othersDairyKnight plays well with othersDairyKnight plays well with others
 
DairyKnight's Avatar
 
Posts: 63
Karma: 2600
Join Date: Oct 2008
Device: PRS-505
muPDF on Kindle DX!!

I have just ported muPDF to Kindle DX, in order to replace the crappy built-in PDF reader. Though still with some bugs and lack a GUI, it could correctly read and render PDF files - see the picture below.

Rough steps to do the magic (for experienced user only ):

1. Download scratchbox arm-eabi prebuilt toolchain. If you are an unlucky Mac user (just as I am...), you'll have to build the toolchain yourself. I used CodeSourcery's patched sources and the makefile from http://fanplastic.org/gcc-for-arm-eabi/ . You'll need macports' patched gmp and mfpr as well. As CodeSourcery's source doesn't have glibc, linux kernel and glibc sources from Amazon site is also necessary.

2. Go get mupdf's source and add the following code to the Jamrules file:


if $(OS) = KINDLE
{
BUILD_X11APP = false ;
CC = {your arm-gcc} ;
CCFLAGS = -march=armv6j {necessary includes and libs directory, you will need to build freetype, zlib, and jpeglib with your arm-gcc} ;

APPLINKLIBS = -lpthread ;

if $(BUILD) = debug { OPTIM = -g -O0 -fno-inline ; }
if $(BUILD) = release { OPTIM = -O3 ; }

#if $(HAVE_JBIG2DEC) { LINKLIBS += -ljbig2dec ; }
#if $(HAVE_OPENJPEG) { LINKLIBS += -lopenjpeg ; }
}

# Dont forget the 'space' before the ; on each variable line !! It is imperative for ftjam.

3. You will need to first build mupdf with:
ftjam OS=LINUX to have the font/cmap generator. copy those executables to build/kindle-x86-debug (no time to polish the script to have better looking names )
and then:
ftjam OS=KINDLE

You might run into problems with gcc, as the keyword 'restrict' used by muPDF is only available for g++. I just did a '#define restrict ' to fix this, but I believe some gurus could provie a more elegant way.

4. Now you should have all the '.a' files ready for muPDF. I just did some slight modification to pdfapp.c for it to work with Kindle DX.
The trick for e-ink display is to write '/dev/fb0', and refresh using: 'echo 2 > /proc/eink_fb/update_display'. There're other commands for this device. You can check the qindle source for details.

And to clear the screen, run 'eips -c' on kindle terminal.

Well, then you have a full functioning PDF reader on Kindle!! Now what's next? hmmm... I can already start thinking about unrestricted zooming, bookmarks, notes, PDF links, smart-crop.... so much more exciting features possible !
DairyKnight is offline   Reply With Quote