From 054a5fbc90e80aca586b091d0245d1240aa8e648 Mon Sep 17 00:00:00 2001 From: Alain Reguera Delgado Date: Sep 11 2012 05:52:39 +0000 Subject: Update `trunk/Scripts/Bash/Functions/Render/Docbook/docbook_convertToPdfFromXml.sh' file. --- diff --git a/Scripts/Bash/Functions/Render/Docbook/docbook_convertToPdfFromXml.sh b/Scripts/Bash/Functions/Render/Docbook/docbook_convertToPdfFromXml.sh index 2db4370..819866f 100755 --- a/Scripts/Bash/Functions/Render/Docbook/docbook_convertToPdfFromXml.sh +++ b/Scripts/Bash/Functions/Render/Docbook/docbook_convertToPdfFromXml.sh @@ -63,20 +63,12 @@ function docbook_convertToPdfFromXml { # Print action message. - if [[ -f ${FILE}.sgml.pdf ]];then - cli_printMessage "${FILE}.xml.pdf" --as-updating-line - else - cli_printMessage "${FILE}.xml.pdf" --as-creating-line - fi + cli_printMessage "${FILE}.pdf" --as-creating-line local -a STYLE_TEMPLATE local -a STYLE_INSTANCE local STYLE_INSTANCE_FINAL='' - # Define name of temporal directory where the DocBook to PDF - # transformation will take place. - local TMPDIR=$(cli_getTemporalFile "docbook2pdf") - # Define absolute path to DocBook source file. This is the # repository documentation manual file where DOCTYPE and ENTITY # definition lines are set. @@ -85,54 +77,37 @@ function docbook_convertToPdfFromXml { # Define absolute path to PDF target file. This is the final # location the PDF file produced as result of DocBook to PDF # transformation will be stored in. - local DST="${FILE}.xml.pdf" + local DST="${FILE}.pdf" # Define file name of formatting object (.fo) file. This file is # an intermediate file needed to produced the PDF. - local FO=$(basename ${FILE}).fo + local FO=$(echo ${INSTANCE} | sed -r 's/docbook$/fo/g') # Define file name of PDF file. This is the file we were looking # for and the one moved, once produced. - local PDF=$(basename ${FILE}).pdf + local PDF=$(echo ${INSTANCE} | sed -r 's/docbook$/pdf/g') # Prepare XSL final instances used in transformations. - docbook_prepareStyles "${DOCBOOK_STYLES_DIR}/docbook2fo.xsl" + docbook_prepareStyles "${DOCBOOK_XSL_DIR}/docbook2fo.xsl" - # Verify temporal directory and create it if doesn't exist. - if [[ ! -d $TMPDIR ]];then - mkdir $TMPDIR - fi - - # Move inside temporal directory. - pushd $TMPDIR > /dev/null + # Create link to `Images' directory. This is the directory where + # images used by documentation are stored in. + ln -s ${TCAR_WORKDIR}/trunk/Identity/Images/Webenv $(dirname ${INSTANCE})/Images # Create formatting object supressing output from stderr. - xsltproc --output ${FO} ${STYLE_INSTANCE_FINAL} ${SRC} &> /dev/null - - # Create PDF format from formatting object. The `pdfxmltex' - # command (which uses the `PassiveTex' engine) must be executed - # twice in order for the document's cross references to be built - # correctly. - if [[ $? -eq 0 ]];then - pdfxmltex ${FO} > /dev/null - pdfxmltex ${FO} > /dev/null - else - cli_printMessage "`gettext "Cannot produce the formatting object."`" --as-error-line - fi + xsltproc --output ${FO} ${STYLE_INSTANCE_FINAL} ${SRC} # 2> /dev/null - # Verify `pdfxmltex' exit status and, if everything is ok, move - # PDF file from temporal directory to its target location. + # Create PDF format from formatting object. Because we are using + # relative path to access `Images', it is necessary to move the + # directory stack into the temporal directory where instance files + # are created. Otherwise, the location used to load images will + # fail. if [[ $? -eq 0 ]];then - mv $PDF $DST + pushd $(dirname ${INSTANCE}) > /dev/null + xmlto -o $(dirname ${FILE}) pdf ${FO} + popd > /dev/null else cli_printMessage "`gettext "Cannot produce the PDF file."`" --as-error-line fi - # Return to where we initially were. - popd > /dev/null - - # Remove temporal directory and temporal style instances created. - rm -r $TMPDIR - rm ${STYLE_INSTANCE[*]} - }