Hi,
I hope I can find the right language to make myself clear.
I have accidentally discovered that I can read a pdf file from the
command line just by using "less -r":
$ less -r file.pdf
works beautifully and even maintains some formatting.
My shell is bash and my X terminal is mate-terminal: https://manpages.debian.org/bullseye/mate-terminal/mate-terminal.1.en.html
If I launch from the terminal:
$ mate-terminal --full-screen -x /usr/bin/less -r Downloads/08\ Karzoff.pdf
This will open a new fullscreen window, rendering the pdf as intended. https://i.imgur.com/R2opBmj.png
If I launch Caja (GUI file manager), right-click on the pdf > "open
with other application" > "use a custom command > mate-terminal
--full-screen -x /usr/bin/less -r > Open
this will display garbage, that is the pdf source code: https://i.imgur.com/eAynhee.png
Any clue?
I would not expect less(1), when run in a
terminal, to properly format the optional display text of a PDF and
/not/ display (or attempt to display) any of the binary data or PDF instructions.
The results you get when launching from Caja is what I expect to see
from an attempt to less(1) a PDF file.
FWIW, why aren't you using pdftotext(1), which expressly designed
to extract and format the display text of a PDF file?
Look to the behaviour of your mate-terminal, when launched fromthe desktop vs launched from Caja.
I hope I can find the right language to make myself clear.
I have accidentally discovered that I can read a pdf file from the
command line just by using "less -r":
$ less -r file.pdf
works beautifully and even maintains some formatting.
My shell is bash and my X terminal is mate-terminal: https://manpages.debian.org/bullseye/mate-terminal/mate-terminal.1.en.html
If I launch from the terminal:
$ mate-terminal --full-screen -x /usr/bin/less -r Downloads/08\ Karzoff.pdf
This will open a new fullscreen window, rendering the pdf as intended. https://i.imgur.com/R2opBmj.png
If I launch Caja (GUI file manager), right-click on the pdf > "open
with other application" > "use a custom command > mate-terminal
--full-screen -x /usr/bin/less -r > Open
this will display garbage, that is the pdf source code: https://i.imgur.com/eAynhee.png
Any clue?
On 20/10/2022 15:25, Lew Pitcher wrote:
I would not expect less(1), when run in a
terminal, to properly format the optional display text of a PDF and
/not/ display (or attempt to display) any of the binary data or PDF
instructions.
But it does, as evidenced by the screenshot in my OP.
The results you get when launching from Caja is what I expect to see
from an attempt to less(1) a PDF file.
Again, see screenshot 1.
FWIW, why aren't you using pdftotext(1), which expressly designed
to extract and format the display text of a PDF file?
Because pdftotext is not very scriptable and doesn't work as smoothly as "less -r", some control characters are still left over.
Look to the behaviour of your mate-terminal, when launched fromthe desktop vs launched from Caja.
I expect mate-terminal to behave the same way if launched from the
terminal or from a file manager.
My feeling is that the "-r" argument doesn't get processed if launched
from the file manager.
Ottavio Caruso <ottavio2006-usenet2012@yahoo.com> writes:
I hope I can find the right language to make myself clear.
I have accidentally discovered that I can read a pdf file from the
command line just by using "less -r":
$ less -r file.pdf
works beautifully and even maintains some formatting.
That's certainly not my experience.
You probably have the $LESSOPEN environment variable set to invoke
something like pdftotext on the input before displaying it.
`man less` and search for "INPUT PREPROCESSOR".
My shell is bash and my X terminal is mate-terminal:
https://manpages.debian.org/bullseye/mate-terminal/mate-terminal.1.en.html >>
If I launch from the terminal:
$ mate-terminal --full-screen -x /usr/bin/less -r Downloads/08\ Karzoff.pdf >>
This will open a new fullscreen window, rendering the pdf as intended.
https://i.imgur.com/R2opBmj.png
If I launch Caja (GUI file manager), right-click on the pdf > "open
with other application" > "use a custom command > mate-terminal
--full-screen -x /usr/bin/less -r > Open
this will display garbage, that is the pdf source code:
https://i.imgur.com/eAynhee.png
Any clue?
You probably have $LESSOPEN set in your interactive shell but not in
your file manager. In your GUI command, try changing "/usr/bin/less -r"
to "env LESSOPEN=... /usr/bin/less -r".
On Thu, 20 Oct 2022 15:37:51 +0000, Ottavio Caruso wrote:
On 20/10/2022 15:25, Lew Pitcher wrote:
FWIW, why aren't you using pdftotext(1), which expressly designed
to extract and format the display text of a PDF file?
Because pdftotext is not very scriptable and doesn't work as smoothly as
"less -r", some control characters are still left over.
Hmmm, I use it in several scripts to parse data from bank and IRS pdfs. Example
pdftotext -layout $pdf_fn $TMPDIR/xx
On Thu, 20 Oct 2022 11:57:46 -0500, Bit Twister wrote:
On Thu, 20 Oct 2022 15:37:51 +0000, Ottavio Caruso wrote:
On 20/10/2022 15:25, Lew Pitcher wrote:
FWIW, why aren't you using pdftotext(1), which expressly designed
to extract and format the display text of a PDF file?
Because pdftotext is not very scriptable and doesn't work as smoothly as >>> "less -r", some control characters are still left over.
Hmmm, I use it in several scripts to parse data from bank and IRS pdfs. Example
pdftotext -layout $pdf_fn $TMPDIR/xx
And, in the context of the OP's problem as he currently sees it,
#!/bin/bash
# Usage: lesspdfpipe.sh <pdf_file_name>
if [ "$1" ]
then
TARGET=$(tempfile)
if pdftotext -layout "$1" "$TARGET"
then
cat "$TARGET"
fi
fi
Ottavio Caruso <ottavio2006-usenet2012@yahoo.com> writes:
I hope I can find the right language to make myself clear.
I have accidentally discovered that I can read a pdf file from the
command line just by using "less -r":
$ less -r file.pdf
works beautifully and even maintains some formatting.
That's certainly not my experience.
You probably have the $LESSOPEN environment variable set to invoke
something like pdftotext on the input before displaying it.
`man less` and search for "INPUT PREPROCESSOR".
You probably have $LESSOPEN set in your interactive shell but not in
your file manager. In your GUI command, try changing "/usr/bin/less -r"
to "env LESSOPEN=... /usr/bin/less -r".
On Thu, 20 Oct 2022 17:08:09 +0000, Lew Pitcher wrote:
On Thu, 20 Oct 2022 17:06:05 +0000, Lew Pitcher wrote:
On Thu, 20 Oct 2022 11:57:46 -0500, Bit Twister wrote:
On Thu, 20 Oct 2022 15:37:51 +0000, Ottavio Caruso wrote:
On 20/10/2022 15:25, Lew Pitcher wrote:
FWIW, why aren't you using pdftotext(1), which expressly designed
to extract and format the display text of a PDF file?
Because pdftotext is not very scriptable and doesn't work as smoothly as >>>>> "less -r", some control characters are still left over.
Hmmm, I use it in several scripts to parse data from bank and IRS pdfs. Example
pdftotext -layout $pdf_fn $TMPDIR/xx
And, in the context of the OP's problem as he currently sees it,
#!/bin/bash
# Usage: lesspdfpipe.sh <pdf_file_name>
if [ "$1" ]
then
TARGET=$(tempfile)
if pdftotext -layout "$1" "$TARGET"
then
cat "$TARGET"
fi
fi
Or, better yet
#!/bin/bash
# Usage: lesspdfpipe.sh <pdf_file_name>
if [ "$1" ]
then
pdftotext -layout "$1" -
fi
Or, minimallyLESSOPEN='|pdftotext -layout %s -' \
On Thu, 20 Oct 2022 17:06:05 +0000, Lew Pitcher wrote:
On Thu, 20 Oct 2022 11:57:46 -0500, Bit Twister wrote:
On Thu, 20 Oct 2022 15:37:51 +0000, Ottavio Caruso wrote:
On 20/10/2022 15:25, Lew Pitcher wrote:
FWIW, why aren't you using pdftotext(1), which expressly designed
to extract and format the display text of a PDF file?
Because pdftotext is not very scriptable and doesn't work as smoothly as >>>> "less -r", some control characters are still left over.
Hmmm, I use it in several scripts to parse data from bank and IRS pdfs. Example
pdftotext -layout $pdf_fn $TMPDIR/xx
And, in the context of the OP's problem as he currently sees it,
#!/bin/bash
# Usage: lesspdfpipe.sh <pdf_file_name>
if [ "$1" ]
then
TARGET=$(tempfile)
if pdftotext -layout "$1" "$TARGET"
then
cat "$TARGET"
fi
fi
Or, better yet
#!/bin/bash
# Usage: lesspdfpipe.sh <pdf_file_name>
if [ "$1" ]
then
pdftotext -layout "$1" -
fi
On 20/10/2022 15:25, Lew Pitcher wrote:
FWIW, why aren't you using pdftotext(1), which expressly designed
to extract and format the display text of a PDF file?
Because pdftotext is not very scriptable and doesn't work as smoothly as "less -r", some control characters are still left over.
Ottavio Caruso <ottavio2006-usenet2012@yahoo.com> writes:
I hope I can find the right language to make myself clear.
I have accidentally discovered that I can read a pdf file from the
command line just by using "less -r":
$ less -r file.pdf
works beautifully and even maintains some formatting.
That's certainly not my experience.
You probably have the $LESSOPEN environment variable set to invoke
something like pdftotext on the input before displaying it.
`man less` and search for "INPUT PREPROCESSOR".
My shell is bash and my X terminal is mate-terminal:
https://manpages.debian.org/bullseye/mate-terminal/mate-terminal.1.en.html >>
If I launch from the terminal:
$ mate-terminal --full-screen -x /usr/bin/less -r Downloads/08\ Karzoff.pdf >>
This will open a new fullscreen window, rendering the pdf as intended.
https://i.imgur.com/R2opBmj.png
If I launch Caja (GUI file manager), right-click on the pdf > "open
with other application" > "use a custom command > mate-terminal
--full-screen -x /usr/bin/less -r > Open
this will display garbage, that is the pdf source code:
https://i.imgur.com/eAynhee.png
Any clue?
You probably have $LESSOPEN set in your interactive shell but not in
your file manager. In your GUI command, try changing "/usr/bin/less -r"
to "env LESSOPEN=... /usr/bin/less -r".
I don't use less(1) often, and didn't know about the LESSOPEN envar.
On Thu, 20 Oct 2022 16:10:40 -0000 (UTC)
Lew Pitcher <lew.pitcher@digitalfreehold.ca> wrote:
I don't use less(1) often, and didn't know about the LESSOPEN envar.
Out of curiosity , do you read man pages using something other than
less or you don't use man pages often ?
Out of curiosity , do you read man pages using something other than
less or you don't use man pages often ?
I used to be a big fan of pg, but the hassle of installing it now has me using whatever default the system comes with.
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 365 |
Nodes: | 16 (3 / 13) |
Uptime: | 25:02:58 |
Calls: | 7,748 |
Calls today: | 2 |
Files: | 12,888 |
Messages: | 5,740,139 |
Posted today: | 1 |