summaryrefslogtreecommitdiff
path: root/Build/tests/largefile/testlfs-thanh/test-include
blob: f859cd66b4e0731a68a08e9c00779edae52f4521 (plain)
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
#!/bin/bash
# Usage: $0 <image-file> <image-count-per-page> <page-count>
# Example: $0 foo.png 10 2  => include foo.png 10x per page and make 2 pages

set -e
set -u

img="$1"
count="$2"
pages="$3"
output="$img-$count-$pages"

runCmd() {
    echo "running '$@'"
    "$@" || true
    echo ""
}

# gen test file
cat <<EOT > $output.tex
\input test-lfs.tex
\includeImage $img $count $pages
\end
EOT

# compile it
runCmd ./pdftex -ini $output.tex

# validate result
ls -lh $output.pdf
if which pdftoppm > /dev/null; then
    echo "check $output.pdf using pdftoppm"
    runCmd pdftoppm -r 72 $output.pdf $output
    rm -f '*.ppm' || true
fi

if which gs > /dev/null; then
    echo "check $output.pdf using gs"
    runCmd gs -q -dNOPAUSE -r72 -sDEVICE=ppmraw -sOutputFile=/dev/null -dBATCH $output.pdf
fi