Friday, July 18, 2008

An algorithm to render PDF on small devices

I am interested in ebook reader for quite a while. But after trying with a 6-inch e-ink reader (Hanlin V3), I found it is almost useless to read normal PDF files (A4 size) on these devices. The font size is too small, while the page size is too wide. So, a method to render PDF for these small devices is thought about and prototyped. The details are as follow:
  1. Convert pdf to image. I use pdftoppm of xpdf. Such as: pdftoppm -r 180 -f 245 -l 245 -gray -aa yes a.pdf a
  2. Analyze the generated images. Break page into lines.
  3. Divide each line long enough to two segments.
  4. Rearrange the segments into a new page, with half of the width.
A full functional PDF re-flow algorithm is very difficult to implemented. But a more simplified version as above is much easier.

1 comment:

Stand Alone Complex said...

Update almost once a year, hmm.......
The re-flow for text is reasonable, but what about large picture......