Thread: pdftoiliad
View Single Post
Old 04-29-2008, 05:21 PM   #1
IanHelgesen
Member
IanHelgesen has a complete set of Star Wars action figures.IanHelgesen has a complete set of Star Wars action figures.IanHelgesen has a complete set of Star Wars action figures.
 
IanHelgesen's Avatar
 
Posts: 20
Karma: 270
Join Date: Feb 2008
Device: Irex Iliad
Sendtoiliad: Now with ePub support! (was: pdftoiliad)

Attached is a simple script I knocked together this morning in a fit of creative procrastination. This will take one or more pdfs, attempt to extract metadata (title, author, # of pages), create a thumbnail of the first page, and create a directory with the pdf and manifest.xml file, ready for the iliad.

Caveats:
This is the result of a morning's hacking, so it _will_ have bugs. The only one I'm aware of at the moment is that it will fail if the file name has spaces (and probably with other special characters too). I can't seem to get the imaging libraries (used to create the thumbnail) to load these files. Any suggestions on fixing this would be greatly appreciated, as would reports on other problems.

Requirements:
This was made for Unix-ish systems. I'm using it on Ubuntu (8.04), but it should work fine on other versions of Linux, and probably on Mac OS X. While it could theoretically be made to work on Windows, I'm not sure exactly what would need to be done. Also, it has no graphical interface, so it would not be terribly useful without considerable work.

You will need:
Python, Python Imaging Libraries, Popplerutils (pdfinfo, pdftoppm)

Example usage:
pdftoiliad myfile.pdf
This will create output myfile in the current directory.

pdftoiliad -o /mnt/Iliad/Books myfile.pdf
This will place the output in your Iliad books directory (assuming /mnt/Iliad is the Iliad's mount point)

pdftoiliad -m myfile.pdf
This will remove the original file.

I have this set up with nautilus actions so that I can simply right click on a file and have it sent to a directory which is synced to my iliad. To do this (in Gnome), install Nautilus Actions, and create a "Send to Iliad" action. Set the path to "/usr/local/bin/pdftoiliad.py -m -o /home/Library/Iliad/Books" (replacing /home/Library/Iliad/Books with whereever you want to keep your books), and the Parameters to %m. In the conditions tab, enter "*.pdf" in the Filenames spot, and "application/pdf" for Mimetypes.

Cheers,
Ian
Attached Thumbnails
Click image for larger version

Name:	Baen_Contentlister.png
Views:	525
Size:	160.3 KB
ID:	14094  
Attached Files
File Type: gz sendtoiliad.tar.gz (6.1 KB, 337 views)

Last edited by IanHelgesen; 07-14-2008 at 06:03 PM. Reason: Added kusmi's code to antialias covers (smoother picture) and increase contrast.
IanHelgesen is offline   Reply With Quote