Attachment 'SetupDocBookxml2pdf.sh'

Download

#!/bin/sh


# Name of the program
PROG=`basename $0`

# Path of the program
DIST=`dirname $0`

# temporary filename
TMP_FILE=/tmp/${USER}_${PROG}$$
TMP_FILE1=/tmp/${USER}_${PROG}$$.xml
TMP_FILE2=/tmp/${USER}_${PROG}$$.fo

RC=1                            # default exit code

# help for usage
usage() {
    cat 1>&2 << EOF
Usage: $PROG [-h] [-o output] input

 -o output      file path and name of the output file
 -h             displays this help message

 input          input file name
EOF
 exit $RC
}

# processing options
ARGS=`getopt "o:h" $*`
if [ $? -ne 0 ]; then
    usage
fi
set -- $ARGS

# This value is the option 'b'
BOPC=0

for i in $*
do
    # echo $1
    case $1 in
    -o) OUTPUT_FILE=$2; shift 2;;
    -h) RC=0; usage;;
    --) shift;;
    esac
done


# check for correct number of parameters (1 parameter in the example)
case $# in
    1) INPUT_FILE=$1 ;;
    *) usage; exit 1 ;;
esac

if [ -z "$OUTPUT_FILE" ]; then
    OUTPUT_FILE=`basename $(echo $INPUT_FILE | cut -d. -f1)`.pdf
fi

# trap for orderly exit (normal exit, HUP, INT and TERM signals are catched)
# return RC for normal exit
trap 'trap 0; /bin/rm -f $TMP_FILE.*; exit $RC' 0
# return always 1 for ^C, DEL etc.
trap 'trap 0 1 2 15; /bin/rm -f $TMP_FILE.*; exit 255' 1 2 15

INSTALL_DIR=$DIST
export DOCBOOK_DIR=$INSTALL_DIR/docbook

# Java 1.5
export JAVA_PATH=/usr/lib64/jvm/
export JAVA_HOME=$JAVA_PATH/jre/
export PATH=$JAVA_PATH/jre/bin/:$PATH
export CLASSPATH=$CLASSPATH:$JAVA_PATH/jre/lib/rt.jar

JARS=`ls $DOCBOOK_DIR/fop/lib/*.jar`

for JAR in $JARS
do
export CLASSPATH=$CLASSPATH:$JAR
done

export CLASSPATH=$CLASSPATH:$DOCBOOK_DIR/xxe-perso-4_9_0/bin/resolver.jar

xmllint --xinclude --noent -o $TMP_FILE1 $INPUT_FILE
if [ $? -ne 0 ]; then
    RC=1
    echo "Hiba a referenciák feloldásakor!"
    exit 0
fi

java \
  -Djavax.xml.parsers.DocumentBuilderFactory=org.apache.xerces.jaxp.DocumentBuilderFactoryImpl \
  -Djavax.xml.parsers.SAXParserFactory=org.apache.xerces.jaxp.SAXParserFactoryImpl \
  -Dorg.apache.xerces.xni.parser.XMLParserConfiguration=org.apache.xerces.parsers.XIncludeParserConfiguration \
  org.apache.xalan.xslt.Process \
    -ENTITYRESOLVER org.apache.xml.resolver.tools.CatalogResolver \
    -URIRESOLVER org.apache.xml.resolver.tools.CatalogResolver \
    -qc \
    -PARAM body.font.family TimesNewRoman \
    -PARAM title.font.family TimesNewRoman \
    -PARAM draft.mode no \
    -PARAM chapter.autolabel 1 \
    -PARAM appendix.autolabel 1 \
    -PARAM section.autolabel 1 \
    -xsl $DOCBOOK_DIR/docbook-xsl/fo/docbook.xsl \
    -in $TMP_FILE1 \
    -out $TMP_FILE2

$DOCBOOK_DIR/fop/fop -c $DOCBOOK_DIR/fop/fontconfig.xml -fo $TMP_FILE2 -pdf $OUTPUT_FILE

RC=$?
exit 0


#
#
#   Copyright 2008-2011, SoftXS GmbH, Switzerland
#
#   dcb2pdf.sh          Convert docbook xml files to PDF format
#
#   $Revision:  $ $Date:  $
#
#   Description:
#
#   Exit code:          0       - Successful conversion
#                       1       - Error at running dcb2fo.sh
#                       2       - Error at running fo2pdf.sh
#                       255     - Interrupted
#
#   Diagnostics:
#
#   Bugs:
#
#   See also:
#
#   $Log: $
#

New Attachment

File to upload
Rename to
Overwrite existing attachment of same name

Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.
Copyright 2008-2014, SoftXS GmbH, Switzerland