Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

convert e-mails to pdf / ps

1,107 views
Skip to first unread message

Johannes Wiedersich

unread,
May 29, 2009, 3:30:10 PM5/29/09
to
Hi list!

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.

Thanks,

Johannes


--
To UNSUBSCRIBE, email to debian-us...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listm...@lists.debian.org

Jochen Schulz

unread,
May 29, 2009, 4:00:15 PM5/29/09
to
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.
--
In this bunker there are women and children. There are no weapons.
[Agree] [Disagree]
<http://www.slowlydownward.com/NODATA/data_enter2.html>

signature.asc

Todd A. Jacobs

unread,
May 29, 2009, 5:00:18 PM5/29/09
to
On Fri, May 29, 2009 at 09:27:29PM +0200, Johannes Wiedersich wrote:

> Is there a simple approach to convert emails to pdf or ps? It should

If your CUPS configuration includes the installed cups-pdf package and a
configured PDF printer, you should be able to print directly to the
virtual PDF device.

Weeding headers and so forth is mutt's responsibility. You can also set
a custom print command in your muttrc to do anything you like, such as:

set print_command="fold -s | pr -F -l60 | /usr/bin/lp -d pdf-300dpi"

Hope that helps.

--
"Oh, look: rocks!"
-- Doctor Who, "Destiny of the Daleks"

Daryl Styrk

unread,
May 29, 2009, 7:10:06 PM5/29/09
to
On Fri, May 29, 2009 at 09:52:56PM +0200, Jochen Schulz wrote:
>
> mutt + muttprint give acceptable results, but I have no idea how to
> script it.
>


Wow muttprint want the following...


$ aptitude install -s muttprint
Reading package lists... Done
Building dependency tree
Reading state information... Done
Reading extended state information
Initializing package states... Done
Reading task descriptions... Done
The following NEW packages will be installed:
doc-base{a} dvipdfmx{a} lacheck{a} latex-beamer{a} latex-xcolor{a}
libfreezethaw-perl{a} libmldbm-perl{a} libuuid-perl{a} lmodern{a}
muttprint pgf{a} preview-latex-style{a} prosper{a} ps2eps{a}
tetex-extra{a} tex-common{a} texlive{a} texlive-base{a}
texlive-base-bin{a} texlive-base-bin-doc{a} texlive-bibtex-extra{a}
texlive-common{a} texlive-doc-base{a} texlive-extra-utils{a}
texlive-font-utils{a} texlive-fonts-extra{a} texlive-fonts-extra-doc{a}
texlive-fonts-recommended{a} texlive-fonts-recommended-doc{a}
texlive-generic-extra{a} texlive-generic-recommended{a}
texlive-humanities{a} texlive-humanities-doc{a} texlive-lang-croatian{a}
texlive-lang-cyrillic{a} texlive-lang-czechslovak{a}
texlive-lang-danish{a} texlive-lang-dutch{a} texlive-lang-finnish{a}
texlive-lang-french{a} texlive-lang-german{a} texlive-lang-greek{a}
texlive-lang-hungarian{a} texlive-lang-italian{a} texlive-lang-latin{a}
texlive-lang-mongolian{a} texlive-lang-norwegian{a}
texlive-lang-other{a}
texlive-lang-polish{a} texlive-lang-portuguese{a}
texlive-lang-spanish{a}
texlive-lang-swedish{a} texlive-lang-vietnamese{a} texlive-latex-base{a}
texlive-latex-base-doc{a} texlive-latex-extra{a}
texlive-latex-extra-doc{a} texlive-latex-recommended{a}
texlive-latex-recommended-doc{a} texlive-math-extra{a}
texlive-pictures{a} texlive-pictures-doc{a} texlive-pstricks{a}
texlive-pstricks-doc{a} texlive-publishers{a} texlive-publishers-doc{a}
texpower{a} texpower-manual{a} tipa{a}
0 packages upgraded, 69 newly installed, 0 to remove and 0 not upgraded.
Need to get 335MB of archives. After unpacking 669MB will be used.

To print?


--
Daryl Styrk
Naples, FL USA

Javier Barroso

unread,
May 29, 2009, 7:40:07 PM5/29/09
to
On Sat, May 30, 2009 at 1:07 AM, Daryl Styrk <daryl...@gmail.com> wrote:
> On Fri, May 29, 2009 at 09:52:56PM +0200, Jochen Schulz wrote:
>>
>> mutt + muttprint give acceptable results, but I have no idea how to
>> script it.
>>
>
>
> Wow muttprint want the following...
>
>
> $ aptitude install -s muttprint

> 0 packages upgraded, 69 newly installed, 0 to remove and 0 not upgraded.


> Need to get 335MB of archives. After unpacking 669MB will be used.

If you don't want recommend packages:
aptitude -R install muttprint

But seems, like it has many depends, thought here 'only' 100 MB wants
to be downloaded after -R option
...

Regards,

Tony Baldwin

unread,
May 29, 2009, 9:40:10 PM5/29/09
to
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...

Jochen Schulz

unread,
May 30, 2009, 7:30:13 AM5/30/09
to
Daryl Styrk:

> On Fri, May 29, 2009 at 09:52:56PM +0200, Jochen Schulz wrote:
>>
>> mutt + muttprint give acceptable results, but I have no idea how to
>> script it.
>
>
> Wow muttprint want the following...
-- snip

Yeah, sorry. I forgot that muttprint is ridiculously heavy if you don't
use Latex already.

J.
--
The news at ten makes me peevish but animal hospital makes me cry.
[Agree] [Disagree]
<http://www.slowlydownward.com/NODATA/data_enter2.html>

signature.asc
0 new messages