~kris/dots

srice

srice/.local/bin/pdfprint -rw-r--r-- 1.7 KiB
e98f3b03 — Kris Yotam chore: sync local state after restore (push updates, no pull) a month ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/usr/bin/env bash
# pdfprint -- print-ready PDF with proper margins, headers, Shunn-style
set -euo pipefail

usage() {
    echo "Usage: pdfprint <input.md> [--format shunn|book|essay] [--output file.pdf]"
    exit 1
}

[ $# -lt 1 ] && usage

input="$1"; shift
format="essay" output=""

while [ $# -gt 0 ]; do
    case "$1" in
        --format|-f) format="$2"; shift 2 ;;
        --output|-o) output="$2"; shift 2 ;;
        *) echo "Unknown option: $1"; usage ;;
    esac
done

[ -z "$output" ] && output="${input%.md}.pdf"

case "$format" in
    shunn)
        # Standard manuscript format (Shunn)
        pandoc "$input" --pdf-engine=xelatex \
            -V geometry:margin=1in \
            -V fontsize:12pt \
            -V linestretch:2 \
            -V mainfont:"Courier New" \
            -V header-includes:'\usepackage{fancyhdr}\pagestyle{fancy}\fancyhead[R]{\thepage}' \
            -o "$output"
        ;;
    book)
        # Book interior format (6x9, tighter margins)
        pandoc "$input" --pdf-engine=xelatex \
            -V geometry:'paperwidth=6in,paperheight=9in,margin=0.75in,inner=0.875in' \
            -V fontsize:11pt \
            -V linestretch:1.3 \
            -V mainfont:"Linux Libertine" \
            --toc \
            -o "$output"
        ;;
    essay)
        # Clean essay format
        pandoc "$input" --pdf-engine=xelatex \
            -V geometry:margin=1in \
            -V fontsize:12pt \
            -V linestretch:1.5 \
            -V mainfont:"Linux Libertine" \
            -o "$output"
        ;;
    *)
        echo "Unknown format: $format (use shunn, book, or essay)"
        exit 1
        ;;
esac

echo "Created: $output ($format format, $(du -h "$output" | cut -f1))"