summaryrefslogtreecommitdiff
path: root/format/fo/pdf
blob: 6e2b37e4fd9239db82ef1c4c5a7753429a538d1e (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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
case "$USE_BACKEND" in
DEFAULT|DBLATEX)
	case "$1" in
	stylesheet)
	  ;;
	post-process)
	  if [ "$VERBOSE" -ge 1 ]
	  then
	    echo >&2 "Post-process XSL-FO to PDF"
	  fi
	  if [ -z "`type -t $PDFXMLTEX_PATH`" ]
	  then
	    echo >&2 "Can't process, pdfxmltex tool not found at $PDFXMLTEX_PATH."
	    exit 3
	  fi
	  # Work around stupid tetex bug with '_' in filenames
	  # Also work around stupid tetex limitation with long lines
	  # (rhbz #101055) and workaround passivetex limitation for chapter
          # titles starting with L (rhbz #526273)
	  sed -e "s,/>,/>\n,g" \
              -e "s,block>,&\n,g" "$XSLT_PROCESSED" >tmp.fo
	  OUT=output
	  TEXINPUTS="$(dirname "$INPUT_FILE")::$SEARCHPATH"
	  export TEXINPUTS
	  "$PDFXMLTEX_PATH" ${POSTARGS} tmp.fo >$OUT </dev/null || \
       { cat $OUT; exit 1; }
	  [ "$VERBOSE" -ge 2 ] && echo >&2 "First pass complete"
	  # If there were undefined references we need to re-run pdfxmltex.
	  if egrep '^LaTeX Warning: There were undefined references.$' $OUT \
							>/dev/null 2>&1 \
	  || egrep '^LaTeX Warning: Label.s. may have changed\.' $OUT \
							>/dev/null 2>&1
	  then
	    "$PDFXMLTEX_PATH" ${POSTARGS} tmp.fo >$OUT </dev/null
	    [ "$VERBOSE" -ge 2 ] && echo >&2 "Second pass complete"
	    "$PDFXMLTEX_PATH" ${POSTARGS} tmp.fo >$OUT </dev/null
	    if [ "$VERBOSE" -ge 2 ]
	    then
	      echo >&2 "Third pass complete"
	      [ "$VERBOSE" -ge 3 ] && cat $OUT
	    fi
	  fi
	  ${GCP_PATH:-cp} -R -P -p -- *.pdf "$OUTPUT_DIR/$(basename "${XSLT_PROCESSED%.*}").pdf"
	  ;;
	esac
	;;
FOP)
	EXT=$(basename "$0")
	case "$1" in
	stylesheet)
	  ;;
	post-process)
	  if [ "$VERBOSE" -ge 1 ]
	  then
	    echo >&2 "Post-process XSL-FO to PDF"
	  fi
	  #we need to change dir to handle external data objects correctly
	  cd "$OUTPUT_DIR"
	  "$FOP_PATH" ${POSTARGS} -fo "${XSLT_PROCESSED}" -"${EXT}" "$OUTPUT_DIR/$(basename ${XSLT_PROCESSED%.*}).${EXT}"
	  cd -
	  ;;
	esac
	;;
esac