On Thu, 21 Apr 2022 15:47:32 +0100
Ottavio Caruso <
ottavio2006...@yahoo.com> wrote:
> I can view a simplified version of a pdf file with less:
>
> $ less file.pdf
>
> If I press "v" an editor will open but it will show all the pdf garbage.
>
> I would like to redirect the formatted output from less to a text
> editor, for example xed or pluma.
>
> 1)Is there a more elegant way than:
>
>
> $ less file.pdf > /tmp/file.txt && xed /tmp/file.txt
>
> ?
If the editors in question support an option to read from stdin then you can
use that through a pipe. Othherwise I can't think of anything. Beyond that ,
I don't think that less really does any formatting , it just wraps lines
and perhaps a bit more. A decent text editor should be able to do this on its
own so I'm not clear why you want to involve less .Note that there is also
the fmt utility to wrap lines.
> and 2)
>
> Any way to clean up unprintable characters before sending them to xed?
As long as you have a clear idea what the unprintable characters are , then
you can use sed .For example
sed -e 's/\o000//g' -e 's/\o001//g' file.pdf
will omit octets with value 0 or 1. I think the \o000 syntax is GNU
specific.
--
vlaho.ninja/prog