diff options
author | Norbert Preining <norbert@preining.info> | 2019-09-02 13:46:59 +0900 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2019-09-02 13:46:59 +0900 |
commit | e0c6872cf40896c7be36b11dcc744620f10adf1d (patch) | |
tree | 60335e10d2f4354b0674ec22d7b53f0f8abee672 /macros/latex/contrib/pdfreview/pdfreview.sh |
Initial commit
Diffstat (limited to 'macros/latex/contrib/pdfreview/pdfreview.sh')
-rwxr-xr-x | macros/latex/contrib/pdfreview/pdfreview.sh | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/macros/latex/contrib/pdfreview/pdfreview.sh b/macros/latex/contrib/pdfreview/pdfreview.sh new file mode 100755 index 0000000000..f7d93f83f4 --- /dev/null +++ b/macros/latex/contrib/pdfreview/pdfreview.sh @@ -0,0 +1,60 @@ +#!/bin/bash + +# this assumes ghostscript is installed as 'gs - change as needed +ghostscript="gs" + +script_name=`basename "$0"` + +if [ -z "$1" ]; then + echo "Usage: $script_name inputfile.pdf > outputfile.tex" + exit 1 +fi + +if [ ! -f "$1" ]; then + echo "File $1 not found" + exit 1 +fi + +source_doc="$1" + +# doc_header will become the preamble of your generated wrapper document +# edit it according it your own preferences. + +doc_header="\documentclass[letterpaper,10pt]{article} + +\usepackage{mathptmx} + +\usepackage[ + sourcedoc={$source_doc}, + inline=true, + grid=true, + gridcolor=black!30, + trim={2cm 1cm 2cm 1cm}, + bodywidth=0.75, + pageoffset=0, + fontsize=footnotesize, + twocolumn=false, + notesbg=yellow, + notesframe=black, + insertpagemargin=2.5cm, + withnotesonly=false, + staggered=true +]{pdfreview} + +\begin{document} +" + +echo "$doc_header" + +# use ghostscript to obtain the page count from the pdf file +page_count=$($ghostscript -q -dNODISPLAY -c "($source_doc) (r) file runpdfbegin pdfpagecount = quit") + +# write page environment for each of the pages +for (( i=1; i<=$page_count; i++ )) +do + echo "\begin{page}{$i}" + echo "\end{page}" + echo "" +done + +echo "\end{document}" |