Jochen Schulz wrote:
Johannes Wiedersich:
Is there a simple approach to convert emails to pdf or ps? It should
basically work like printing from a mail program, ie. stripping most of
the header except to, from and subject and only print the text of the
email without attachments.
It's quite a few mails in a folder on their own and I don't want to
print them from icedove from the gui.
mutt + muttprint give acceptable results, but I have no idea how to
script it.
J.
I think anyway you do it, aside from scripting, is going to take a few
steps.
I mean, if you save the .eml from icedove, you can open it in a text
editor that will produce pdf, like medit, tickle text, etc.
That's several steps (save, open in text editor, export to pdf).
Or you could simply copy/paste to an editor or even oowriter to do the same.
From the command line, after saving the .eml, you could
enscript it to ps and ps2pdf it.
The .eml file is basically just a plain txt file, really.
Hmmm...you could select the text and then run a script that grabs text
from the clipboard (can be done, but I don't know how) to run it through
enscript and ps2pdf...
Like this (just tried it)
#!/usr/bin/env wish
# get selection, pipe to enscript / ps2pdf
set mytext [selection get -selection PRIMARY]
exec echo $mytext > mytext.txt
exec enscript mytext.txt -q -B -p mytext.ps
exec ps2pdf mytext.ps mytext.pdf
exec rm mytext.txt mytext.ps
exit
I selected some text and ran this, and bang, had me a pdf with the
selected text. It will work with any selected text.
In most decent window managers (read, not gnome, kde, or xfce), it would
easy to set a keybinding to fire the whole thing off.
For instance, in fluxbox, just as an example (about the same in
openbox), one could set the keybinding Mod1+P (alt-p, if you will) to
run this generate pdf script. Stick the script in /usr/local/bin, or
something, call it sel2pdf (ie. selection to pdf), program the binding
(in your ~/.fluxbox/keys file add
Mod1 p :ExecCommand sel2pdf
And then all you would have to do is select the text and bang alt-p.
Of course, that's make it an efficient action once it's all in place,
which is useful if it's something you do repeatedly.
At the same time, there's probably a more efficient way to script it
than using Tcl/wish, then bash commands, and running the text through
both enscript and ps2pdf...There might be a tool that will go straight
to pdf.
Now, I used tcl's selection to get clipboard contents, and then bash to
do everything else, simply because I don't know how to get clipboard
contents otherwise, but there are bash tools for that.
There's something called xclip, but I don't have it installed on my system.
Or, I suppose...now, if you don't want to overwrite mytext.pdf
everytime, you could do:
#!/usr/bin/env wish
# get selection, pipe to enscript / ps2pdf
set filename [clock seconds]
set mytext [selection get -selection PRIMARY]
exec echo $mytext > $filename.txt
exec enscript $filename.txt -q -B -p $filename.ps
exec ps2pdf $filename.ps $filename.pdf
exec rm $filename.txt $filename.ps
exit
or something like that.
It will give you a file like 1243647083.pdf
Likely someone on here knows a lot better than I, and can improve on
this little script. I only started learning bash scripting and tcl
about 18 months ago (despite using only gnu/linux at work/home for
nearly a decade)...Some day I might be a real hacker, but not yet.
/tony
--
http://www.baldwinsoftware.com
free/open source software
tcl yer os with a feather...
--
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org