Discussion:
Reading PDFs on the command line (with misc/lesspipe)
(too old to reply)
Niklaas Baudet von Gersdorff
2016-06-29 10:29:45 UTC
Permalink
Since I use mutt to read emails on my server, I would like to
read PDFs on the command line. How can I do that?

I installed misc/lesspipe and -- as far as I can judge --
configured it properly.

$ echo $LESSOPEN
|/usr/local/bin/lesspipe.sh %s

However, if I run

$ less some.pdf

I still get an unreadable output of fancy symbols.

Has anybody got lesspipe running properly? Or are there even
better approaches for reading PDF on the command line?

Niklaas
Ralf Mardorf via freebsd-questions
2016-06-29 11:26:33 UTC
Permalink
Post by Niklaas Baudet von Gersdorff
$ less some.pdf
http://www.manualpages.de/FreeBSD/FreeBSD-ports-9.0-RELEASE/man1/pdftotext.1.html
http://unix.stackexchange.com/questions/41362/view-pdf-file-in-terminal

I wonder how it is handled assumed "some.pdf" is just a scanned picture
of text converted to pdf ;).
Martin S. Weber
2016-06-29 11:36:45 UTC
Permalink
Post by Ralf Mardorf via freebsd-questions
Post by Niklaas Baudet von Gersdorff
$ less some.pdf
http://www.manualpages.de/FreeBSD/FreeBSD-ports-9.0-RELEASE/man1/pdftotext.1.html
http://unix.stackexchange.com/questions/41362/view-pdf-file-in-terminal
I wonder how it is handled assumed "some.pdf" is just a scanned picture
of text converted to pdf ;).
It (pdftotext in.pdf -) just outputs a blank line for image based PDFs.

Regards,
-Martin
Polytropon
2016-06-29 11:40:31 UTC
Permalink
Post by Niklaas Baudet von Gersdorff
Since I use mutt to read emails on my server, I would like to
read PDFs on the command line. How can I do that?
I'm using the pdftotext command, part of the xpdf package.
Its output can be redirected.
Post by Niklaas Baudet von Gersdorff
I installed misc/lesspipe and -- as far as I can judge --
configured it properly.
$ echo $LESSOPEN
|/usr/local/bin/lesspipe.sh %s
However, if I run
$ less some.pdf
I still get an unreadable output of fancy symbols.
Probably there is no processing step included?
--
Polytropon
Magdeburg, Germany
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...
Olivier
2016-06-29 11:41:08 UTC
Permalink
Post by Ralf Mardorf via freebsd-questions
Post by Niklaas Baudet von Gersdorff
$ less some.pdf
http://www.manualpages.de/FreeBSD/FreeBSD-ports-9.0-RELEASE/man1/pdftotext.1.html
http://unix.stackexchange.com/questions/41362/view-pdf-file-in-terminal
I wonder how it is handled assumed "some.pdf" is just a scanned picture
of text converted to pdf ;).
/usr/local/libexec/xpdf/pdfimages is installed by default by package
xpdf.

Olivier
Post by Ralf Mardorf via freebsd-questions
_______________________________________________
https://lists.freebsd.org/mailman/listinfo/freebsd-questions
--
Polytropon
2016-06-29 12:03:16 UTC
Permalink
Post by Olivier
Post by Ralf Mardorf via freebsd-questions
Post by Niklaas Baudet von Gersdorff
$ less some.pdf
http://www.manualpages.de/FreeBSD/FreeBSD-ports-9.0-RELEASE/man1/pdftotext.1.html
http://unix.stackexchange.com/questions/41362/view-pdf-file-in-terminal
I wonder how it is handled assumed "some.pdf" is just a scanned picture
of text converted to pdf ;).
/usr/local/libexec/xpdf/pdfimages is installed by default by package
xpdf.
And then use ImageMagick to convert it to ASCII art. :-)
--
Polytropon
Magdeburg, Germany
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...
Bertram Scharpf
2016-06-29 12:16:00 UTC
Permalink
Post by Ralf Mardorf via freebsd-questions
Post by Niklaas Baudet von Gersdorff
Since I use mutt to read emails on my server, I would like to
read PDFs on the command line. How can I do that?
$ less some.pdf
I wonder how it is handled assumed "some.pdf" is just a scanned picture
of text converted to pdf ;).
I do the following (from the shell, not yet from mutt):

- Forward X to the desktop machine:

xto() {
local h l d
h=${1:-desktop}
l=`hostname -f`
d=":0"
ssh $h "
export DISPLAY=$d
xhost $l 1>&2
xauth extract - $d
" | xauth -f ~/.Xauthority merge -
export DISPLAY=$h$d
}

- Run xpdf.

Of course, this requires xpdf and a lot of X client stuff to
be installed on the (anything but X) server.

You could also try to scp the PDF to the desktop and run
xpdf there via ssh.

Bertram
--
Bertram Scharpf
Stuttgart, Deutschland/Germany
http://www.bertram-scharpf.de
Ralf Mardorf via freebsd-questions
2016-06-29 12:24:09 UTC
Permalink
Post by Polytropon
Post by Olivier
Post by Ralf Mardorf via freebsd-questions
I wonder how it is handled assumed "some.pdf" is just a scanned
picture of text converted to pdf ;).
/usr/local/libexec/xpdf/pdfimages is installed by default by package
xpdf.
And then use ImageMagick to convert it to ASCII art. :-)
:D
Niklaas Baudet von Gersdorff
2016-06-30 08:58:29 UTC
Permalink
Polytropon [2016-06-29 14:03 +0200] :

[...]
Post by Polytropon
Post by Olivier
Post by Ralf Mardorf via freebsd-questions
http://www.manualpages.de/FreeBSD/FreeBSD-ports-9.0-RELEASE/man1/pdftotext.1.html
http://unix.stackexchange.com/questions/41362/view-pdf-file-in-terminal
I wonder how it is handled assumed "some.pdf" is just a scanned picture
of text converted to pdf ;).
/usr/local/libexec/xpdf/pdfimages is installed by default by package
xpdf.
Thanks for the second link. That made me realise that
misc/lesspipe uses xpdf's pdftotext to view the PDF. I thought
that I wouldn't need xpdf's utils if I had lesspipe installed.
Post by Polytropon
And then use ImageMagick to convert it to ASCII art. :-)
Haha. Great idea. However, I simply want to get a glimpse of what
is written in the PDF before I start downloading it with scp.
Post by Polytropon
xto() {
local h l d
h=${1:-desktop}
l=`hostname -f`
d=":0"
ssh $h "
export DISPLAY=$d
xhost $l 1>&2
xauth extract - $d
" | xauth -f ~/.Xauthority merge -
export DISPLAY=$h$d
}
- Run xpdf.
Of course, this requires xpdf and a lot of X client stuff to
be installed on the (anything but X) server.
This looks very interesting. Thanks for sharing!

Niklaas

Loading...