Nat says…

Taco “Nat” Buitenhuis

using an mp3 player as an “ebook reader”

with 14 comments

Lots of people are finding this post through search engines. What are you looking for, people? Something that can show text and play mp3s, something that can change text into mp3s, or something else? Please do tell me in a comment! I’m not just curious, I actually know how to change text into speech automatically. I just haven’t tried it yet. OTOH, if you’re just looking for an ebook reader that can play mp3s… I don’t know, why don’t you get yourself an EeePC or something?

Every once in a while, a geek’s gotta do what a geek’s gotta do, so… Report, meet mp3 player. Mp3 player, meet report.

We’re going to try to display a report I wrote in LaTeX as a slideshow on my large screen (ho hum) mp3 player.

First, we’ll adapt the LaTeX source file so it will generate pages the size of the screen of our “ebook reader”.

We don’t want a4 paper (duh), and we want a small font so more text will fit on the screen, so we replace

\documentclass[a4paper]{article}

by

\documentclass[10pt]{article} .

We look up the screen resolution of the “ebook reader” on the net, it’s 128 x 160 pixels. We add the following:

\usepackage[vcentering,dvips]{geometry}
\geometry{papersize={128pt,160pt},total={108pt,140pt}}

Note that the second two numbers create a tiny margin. I know points (pt) and pixels are not the same thing, but for our purpose they will be.

We disable the useless automatically generated parts of the document by prefixing their commands with a % :

%\maketitle
%\tableofcontents
%\listoftables
%\listoffigures

Now we’re ready to compile the document with the usual command:

latex report.tex

Oops! We get lots of warnings about overfull hboxes. LaTeX has very nice two-side justification enabled by default, but on this scale it just won’t work because not enough words will fit on a line to make it look good. So, we’ll use the less pretty left justification instead. Insert this somewhere after \begin{document} : \raggedright . There, problem solved. Now re-run latex report.tex until it stops complaining about cross-references.

Now we have a dvi file, but what we want is a set of jpg files (the mp3 player doesn’t support any other image format). Fine. First we’ll make a postscript document:

dvips -o report.ps report.dvi

And then we’ll convert it to jpg files:

convert -antialias -negate report.ps rep%03d.jpg

Convert is part of the imagemagick package. This will generate a bunch of jpg files, named rep000.jpg, rep001.jpg, etc. -antialias should make the result a bit prettier, and -negate will change it to white text on black background, which should be easier on the eyes and maybe also on the batteries.

We use our favorite image viewer to verify everything looks alright (it does), and copy the files to our mp3 player, er, ebook reader. We’re done, only the mp3 player shows black screens instead of the text. I guess it doesn’t even support jpg very well, maybe a firmware update will fix that but I can’t be bothered to take the risks of that for something as silly as this. It’s a samsung yp-z5f if anyone’s curious.

We failed at the last step, thanks to proprietary software on the mp3 player. Still, I’d like to see you try this with an MS Word file, and get as nice results with this litte work:

rep024.jpg

rep039.jpg

Because LaTeX takes care of most of the formatting for you, it is much more flexible than WYSIWYG word processors.

Just to prove a point:

file rep000.jpg
rep000.jpg: JPEG image data, JFIF standard 1.01

See? It’s a real jpg. Nothing wrong with it. Oh well.

LaTeX tip of the day: include images this way:

\includegraphics[width=<SCALE>\textwidth]{<FILENAME>}

where <SCALE> would be, for example, .5 to make the image half as wide as the text. This way your images will never be too wide for the page, no matter what paper size you choose.

Written by Nat

2008/2/4 at 15:37:29

14 Responses

Subscribe to comments with RSS.

  1. This is exactly what I was looking for. It’s easy to generated formatted LateX files with Open Office.org. I will try this as soon as possible.

    Thanks

    RD

    2008/2/18 at 0:53:10

  2. Let me know how that goes. I just had a look at some LaTeX generated by OpenOffice, and I think you may need to delete everything before \begin{document} and replace it by these commands:

    \documentclass[10pt]{article}
    \usepackage[T1]{fontenc}
    \usepackage{txfonts}
    \usepackage[vcentering,dvips]{geometry}
    \geometry{papersize={128pt,160pt},total={108pt,140pt}}
    \usepackage{color,graphicx}

    I especially wonder what will happen to illustration and special formatting.

    Taco

    2008/2/18 at 10:03:18

  3. I am purchasing an mp3 player (samsung yp s5) and it includes the text feature, and i would like to read ebooks on there, however the only supported format for text files are .txt (plain text). Most ebooks dont have plain text there is juse Adobe, Mobipocket, and Mocrosoft reader. Is there a garunteed way to convert those formats in to plain text?? Please HELP ME!!!!!!!!!!!!!!

    Safiyyah

    2008/4/27 at 0:01:01

  4. @Safiyyah:

    Open the document on your computer, select all text, copy the text, open a plain text editor (on windows this would be notepad), paste the text in that editor, save, and you’re done.

    Of course many ebooks are protected against this trick :/ .

    On Linux and other UNIX-like operating systems there are many conversion utitilities with names like “pdftotext”.

    Nat

    2008/4/27 at 12:04:35

  5. Okay thank you, but since many ebooks are protected against copy & pasting….what can i do? What is Linux and other UNIX-like operating systems i have windows…..

    thanx
    Nat

    Safiyyah Muhammad

    2008/4/30 at 14:26:58

  6. What can you do to get the text out of a protected ebook?

    The shortest answer is “nothing”. You might take a screenshot of each page and then feed those images to OCR software… but that’s really not worth the effort. Also, note that you may need to switch on a “text selection” tool in the document viewer to be able to copy-paste. Also, if I remember correctly, acroread has a “save as text” menu item in the file menu.

    The somewhat longer answer is that someone somewhere may have made a program to do that, but you’re asking the wrong person. I don’t know much about software for MS Windows, I never used that operating system for anything else than simple office tasks … and even that was many years ago. By the way, please note that depending on where you live, it may be illegal to break the copy protection of an ebook you paid for. Silly but true.

    The ultimate answer is that your computer isn’t doing what you want (converting some ebook format to plain text), but what someone else wants it to do (which is refusing to do what you want). It’s an annoying situation which is a natural result of using software of which you don’t have the human-readable code. If you did had that sourcecode, you (or someone else) could modify it to ignore the “disallow copying” information in ebook files. Unfortunately I’m not sure if such software (known as “free software” or “freedomware” or “open source” ) is available for all ebook formats. PDF is no problem, about the others I don’t know. It’s difficult to create software that reads file formats that are not published standards…

    As far as possible, I use only software that I’m allowed to modify. This is one of the reasons I don’t use MS Windows. Another reason is that Windows simply can’t be made to work the way I like (this can be argued to be the same reason in different words). Linux (more precisely GNU/Linux) is what I use. If you’re curious, I recommend this website: http://www.getgnulinux.org/

    UNIX is a group of operating systems that are all derived from one operating system designed very long ago, that are certified to match some standards. For example Solaris and BSD are UNIX, and – surprise! – so is MacOS X (if I’m not mistaken. at least it is UNIX-like, see next paragraph).

    UNIX-like is a bigger group of operating systems, that all resemble UNIX. Most of these allow you to work in a graphical environment similar to what you’re used to from Windows, but all also have a text based working environment (”command line”). The general method of using the command line is to write a description of what you want in some plain text file(s), run some small program(s), and find what you want in a new file made by said programs. This may seem primitive, but it allows for really advanced automation of tasks. For example a few years ago I was in a situation where images and bits of text were shared between a few documents. I made it so that after modifying some image or text, I would have to type only one word on the command line, and my computer would figure out which documents needed to be updated, would update them, and then upload both pdf and html versions to my website. This automation was quite easy to do!

    To convert an ebook to plain text, I would type this on the command line:

    pdftotext AliceInWonderland.pdf AliceInWonderland.txt

    Super easy, but works only for pdf files. For other filetypes there are other commands (for example antiword or catdoc for MS Word files), but as I said before I don’t know if these are available for all ebook filetypes. Usually a good strategy is to first “print” them to a postscript (ps) file in Windows, and then use ps2txt on Linux. Chances are that if copy-pasting isn’t allowed, printing isn’t allowed either, though.

    Nat

    2008/5/1 at 12:02:49

  7. Anything that can be displayed can be converted to text, for microsoft reader ebooks look for a program called c-lit (without the dash). PDFtotxt as above. There are a number of players that make a good txt ebook reader eg the Laser MP4-V970-8G

    Justin

    2008/9/3 at 0:35:50

  8. [...] capable of displaying images… How to make something out of that? I found a simple solution on this weblog, converting a text file using Latex into a 1500 page pdf with pages of 320×240 points (pt). [...]

  9. I have had the same problem with my mp3 player (a Philips GoGear), solved adding the “-colorspace RGB” option to the convert command.
    It seems that by default convert produces CYMK-ed jpegs that some devices don’t like.

    Marco

    2008/10/5 at 19:29:48

  10. [...] utile in alcune occasioni. Se invece il lettore supporta solamente la visualizzazione di immagini, questo sito mi ha suggerito una procedura per trasformare il testo in una serie di immagini jpg [...]

  11. You asked for explanations for search hits, so…

    In my case, I came here because I’m trying to figure out how to format a plain text file so it will display in an MP3 player for reading. My kid got one of those super-cheap media players that are made in China and only accept video in AMV format – another pain altogether. :(

    Anyway, it takes a text file alright, both Unix and DOS format, but it translates line breaks as spaces no matter what, and only has a buffer 16 characters wide and 8 lines long, so this makes it difficult to read. I’m looking for a work-around hack, or mainly to find out what, if any, standard for text these things use.

    If I find nothing else, I can always write a sed script to re-format a text file for easy reading! :)

    Hope that was interesting…

    Penguin Pete

    2008/11/15 at 0:14:56

  12. I was looking to see if it was worth messing around with image files to put/transfer them via an MP3 player, which I’ve got, instead of having to buy a memory stick. On balance I think the memory stick is easier!

    Ellie

    2009/2/8 at 0:33:45

    • You can put image files on an MP3 player the same way you would put them on an USB stick. The only difference is that the stick doesn’t have a screen :) .

      Nat

      2009/2/8 at 9:58:15

  13. I actually wanted to know how to convert ebook files into mp3 files. If it could also split the pages up into individual files, that would be even better (I know by chaperter is ask way too much).

    Sam

    2009/2/15 at 5:08:10


Leave a Reply