nnn/plugins/pdfview

25 lines
617 B
Plaintext
Raw Normal View History

2019-05-05 15:26:37 +00:00
#!/usr/bin/env sh
# Description: View a PDF file in pager
#
2019-05-31 18:47:19 +00:00
# Notes:
2021-05-15 17:32:01 +00:00
# - $PAGER must be 'less -R' or 'most'
# - To use mutool, uncomment the relevant lines and comment the pdftotext line
2019-05-31 18:47:19 +00:00
#
2019-05-05 15:26:37 +00:00
# Shell: POSIX compliant
# Author: Arun Prakash Jana
2020-11-22 14:39:14 +00:00
if [ -n "$1" ]; then
2019-11-21 20:44:25 +00:00
if [ "$(head -c 4 "$1")" = "%PDF" ]; then
2019-05-31 18:47:19 +00:00
# Convert using pdftotext
2019-05-05 15:26:37 +00:00
pdftotext -nopgbrk -layout "$1" - | sed 's/\xe2\x80\x8b//g' | $PAGER
2019-05-31 18:47:19 +00:00
# Convert using mutool
# file=`basename "$1"`
# txt=/tmp/"$file".txt
# mutool convert -o "$txt" "$1"
# eval $PAGER $txt
# rm "$txt"
2019-05-05 15:26:37 +00:00
fi
fi