docbook-to-pdf 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #!/bin/sh
  2. if [ -z "$1" -o -z "$2" ]; then
  3. echo "usage: [-v] $0 <docbook file> <templatedir>"
  4. echo
  5. echo "*NOTE* you need xsltproc, fop and nwalsh docbook stylesheets"
  6. echo " installed for this to work!"
  7. echo
  8. exit 0
  9. fi
  10. FO=`echo $1 | sed s/.xml/.fo/` || exit 1
  11. PDF=`echo $1 | sed s/.xml/.pdf/` || exit 1
  12. TEMPLATEDIR=$2
  13. ##
  14. # These URI should be rewritten by your distribution's xml catalog to
  15. # match your localy installed XSL stylesheets.
  16. XSL_BASE_URI="http://docbook.sourceforge.net/release/xsl/current"
  17. # Creates a temporary XSL stylesheet based on titlepage.xsl
  18. xsltproc -o /tmp/titlepage.xsl \
  19. --xinclude \
  20. $XSL_BASE_URI/template/titlepage.xsl \
  21. $TEMPLATEDIR/titlepage.templates.xml || exit 1
  22. # Creates the file needed for FOP
  23. xsltproc --xinclude \
  24. --stringparam hyphenate false \
  25. --stringparam formal.title.placement "figure after" \
  26. --stringparam ulink.show 1 \
  27. --stringparam body.font.master 9 \
  28. --stringparam title.font.master 11 \
  29. --stringparam draft.watermark.image "$TEMPLATEDIR/draft.png" \
  30. --stringparam chapter.autolabel 1 \
  31. --stringparam appendix.autolabel A \
  32. --stringparam section.autolabel 1 \
  33. --stringparam section.label.includes.component.label 1 \
  34. --output $FO \
  35. $TEMPLATEDIR/db-pdf.xsl \
  36. $1 || exit 1
  37. # Invokes the Java version of FOP. Uses the additional configuration file common/fop-config.xml
  38. fop -c $TEMPLATEDIR/fop-config.xml -fo $FO -pdf $PDF || exit 1
  39. rm -f $FO
  40. rm -f /tmp/titlepage.xsl
  41. echo
  42. echo " #### Success! $PDF ready. ####"
  43. echo