mirror of
https://github.com/jarun/nnn.git
synced 2024-11-16 16:13:16 +00:00
25 lines
613 B
Bash
Executable file
25 lines
613 B
Bash
Executable file
#!/usr/bin/env sh
|
|
|
|
# Description: View a PDF file in pager
|
|
#
|
|
# Notes:
|
|
# - $PAGER must be 'less -R' or 'most'
|
|
# - To use mutool, uncomment the relevant lines and comment the pdftotext line
|
|
#
|
|
# Shell: POSIX compliant
|
|
# Author: Arun Prakash Jana
|
|
|
|
if [ -n "$1" ]; then
|
|
if [ "$(head -c 4 "$1")" = "%PDF" ]; then
|
|
# Convert using pdftotext
|
|
pdftotext -nopgbrk -layout "$1" - | sed 's/\xe2\x80\x8b//g' | $PAGER
|
|
|
|
# Convert using mutool
|
|
# file=`basename "$1"`
|
|
# txt=/tmp/"$file".txt
|
|
# mutool convert -o "$txt" "$1"
|
|
# eval $PAGER $txt
|
|
# rm "$txt"
|
|
fi
|
|
fi
|