Thread: chm2sony-pdf
View Single Post
Old 07-29-2008, 09:52 PM   #1
krtekz
Member
krtekz began at the beginning.
 
Posts: 16
Karma: 10
Join Date: Jul 2008
Device: ipod touch, axim x30
chm2sonypdf

So far, I find the following method quite satisfying for reading chm files on Sony Reader, especially for programming related chm documents with a lot of code listings. For these docs, a critical requirement is to preserve the format of code listings. The new PDF reflow feature works well for 'pure text' docs, but might destroys codes.

Step 1: Convert chm to pdf of size exactly the same as reader's viewable area, in landscape mode.
Step 2: Rotate the pdf 90 degrees anticlockwise.

This way, docs are shown in landscape without switching to reader's landscape mode. And no reflow is needed so original format is intact.

I use chm2pdf and pdftk. They are available in standard Debian/Ubuntu repository and might also be in other distributions' repositories. The simple script is here, usage: chm2sonypdf file.chm
Code:
#!/bin/sh
set -x
chm2pdf --webpage --continuous --textfont helvetica --fontsize 10 --size 4.54x3.47in --no-numbered --gray --header . --footer . --no-toc --top 0 --right 0 --bottom 0 --left 0 $1 $1.tmp.pdf
pdftk $1.tmp.pdf cat 1-endW output $1.sony.pdf
rm -f $1.tmp.pdf
BTW, all the internal links are preserved.

sample file attached:
Attached Files
File Type: pdf CPP.excerpt.pdf (121.2 KB, 275 views)

Last edited by krtekz; 07-30-2008 at 08:36 AM.
krtekz is offline   Reply With Quote