1 Oct 2006 08:57
Re: mailcap
Bob Proulx <bob <at> proulx.com>
2006-10-01 06:57:46 GMT
2006-10-01 06:57:46 GMT
Toby wrote:
> Bob Proulx wrote:
> > That implies to me that you want a text mode pdf reader.
>
> FYI pdftotext (from xpdf-utils) gives a readable output from most PDFs
Oh very good! I had not known about pdftotext before. But looking at
it I see that it requires an input file as a file and won't read
stdin. Therefore it appears to me that it needs a wrapper script to
adapt it nicely for use in mailcap. Here is one possibility.
#!/bin/sh
case $1 in
*.pdf)
TMPNAME="$(dirname "$1")/$(basename "$1" .pdf).txt"
trap 'rm -f "$TMPNAME"' EXIT
pdftotext "$1"
cat "$TMPNAME"
exit 0
;;
esac
echo "Error: Needs NAME.pdf file argument." 1>&2
exit 1
With that pdftotext.sh wrapper then the following mailcap entry works
for me.
application/pdf; pdftotext.sh '%s'; copiousoutput; description=Portable Document Format; nametemplate=%s.pdf
Bob
(Continue reading)
RSS Feed