aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/pdfview
blob: 2b953b5d85cb1330e903f0f88fc7498b96dcbb9e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/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 ! [ -z "$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