|
|
2fa604 |
#!/bin/bash
|
|
|
2fa604 |
#
|
|
|
2fa604 |
# docbook_convertToPdfFromSgml.sh -- This function transforms DocBook
|
|
|
2fa604 |
# files which have set the SGML DTD in them. To produce PDF from
|
|
|
2fa604 |
# DocBook SGML DTD, we take the DocBook XML DTD file and change its
|
|
|
2fa604 |
# DTD from XML to SGML. Since XML is SGML shoudn't be any problem.
|
|
|
7e4aec |
# Once the DTD has been changed from XML to SGML, we use openjade
|
|
|
7e4aec |
# (through `jw' shell script) to convert the SGML-based DocBook file
|
|
|
7e4aec |
# to PDF. Customization can be achieved through DSL
|
|
|
7e4aec |
# (docbook-style-dsssl-1.79-4.1) shipped in this distribution.
|
|
|
7e4aec |
#
|
|
|
7e4aec |
# In this configuration and using default configuration settings, I've
|
|
|
7e4aec |
# presented the following problems:
|
|
|
7e4aec |
#
|
|
|
2fe9b7 |
# 1. It is not possible to produce localized PDF outputs through
|
|
|
2fe9b7 |
# `xml2po', the default way of producing localized content inside
|
|
|
2fe9b7 |
# `centos-art.sh' script.
|
|
|
7e4aec |
#
|
|
|
7e4aec |
# In this configuration and using default configuration settins, I've
|
|
|
7e4aec |
# presented the following advantages:
|
|
|
7e4aec |
#
|
|
|
2fe9b7 |
# 1. The PDF output produced from SGML-based files seem to be better
|
|
|
2fe9b7 |
# looking an less buggy than PDF output produced from XML-based
|
|
|
2fe9b7 |
# files, visually I mean.
|
|
|
7e4aec |
#
|
|
|
7e4aec |
# To make the whole process transparent, a temporal directory is
|
|
|
7e4aec |
# created for intermediate works and final files are moved then to
|
|
|
7e4aec |
# their final location.
|
|
|
2fa604 |
#
|
|
|
2fe9b7 |
# Copyright (C) 2009, 2010, 2011 The CentOS Project
|
|
|
2fa604 |
#
|
|
|
2fa604 |
# This program is free software; you can redistribute it and/or modify
|
|
|
2fa604 |
# it under the terms of the GNU General Public License as published by
|
|
|
2fa604 |
# the Free Software Foundation; either version 2 of the License, or (at
|
|
|
2fa604 |
# your option) any later version.
|
|
|
2fa604 |
#
|
|
|
2fa604 |
# This program is distributed in the hope that it will be useful, but
|
|
|
2fa604 |
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
2fa604 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
2fa604 |
# General Public License for more details.
|
|
|
2fa604 |
#
|
|
|
2fa604 |
# You should have received a copy of the GNU General Public License
|
|
|
2fa604 |
# along with this program; if not, write to the Free Software
|
|
|
2fa604 |
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
2fa604 |
#
|
|
|
2fa604 |
# ----------------------------------------------------------------------
|
|
|
2fa604 |
# $Id$
|
|
|
2fa604 |
# ----------------------------------------------------------------------
|
|
|
2fa604 |
|
|
|
2fa604 |
function docbook_convertToPdfFromSgml {
|
|
|
2fa604 |
|
|
|
2fa604 |
# Print action message.
|
|
|
7e4aec |
if [[ -f ${FILE}.sgml.pdf ]];then
|
|
|
7e4aec |
cli_printMessage "${FILE}.sgml.pdf" --as-updating-line
|
|
|
7e4aec |
else
|
|
|
7e4aec |
cli_printMessage "${FILE}.sgml.pdf" --as-creating-line
|
|
|
7e4aec |
fi
|
|
|
2fa604 |
|
|
|
2fa604 |
local -a STYLE_TEMPLATE
|
|
|
2fa604 |
local -a STYLE_INSTANCE
|
|
|
2fa604 |
local STYLE_INSTANCE_FINAL=''
|
|
|
2fa604 |
|
|
|
7e4aec |
# Define name of temporal directory where the DocBook to PDF
|
|
|
7e4aec |
# transformation will take place.
|
|
|
7e4aec |
local TMPDIR=$(cli_getTemporalFile "docbook2pdf")
|
|
|
7e4aec |
|
|
|
7e4aec |
# Define absolute path to DocBook source file. This is the
|
|
|
7e4aec |
# repository documentation manual file where DOCTYPE and ENTITY
|
|
|
7e4aec |
# definition lines are set.
|
|
|
7e4aec |
local SRC=${INSTANCE}
|
|
|
2fa604 |
|
|
|
7e4aec |
# Define absolute path to PDF target file. This is the final
|
|
|
7e4aec |
# location the PDF file produced as result of DocBook to PDF
|
|
|
7e4aec |
# transformation will be stored in.
|
|
|
7e4aec |
local DST="${FILE}.sgml.pdf"
|
|
|
7e4aec |
|
|
|
7e4aec |
# Define file name of PDF file. This is the file we were looking
|
|
|
7e4aec |
# for and the one moved, once produced.
|
|
|
7e4aec |
local PDF=$(basename ${SRC} | sed -r 's!\.docbook$!.pdf!')
|
|
|
2fa604 |
|
|
|
2fa604 |
# Replace document definition from XML to SGML.
|
|
|
2fa604 |
sed -i -r \
|
|
|
2fa604 |
-e 's!"-//OASIS//DTD DocBook XML!"-//OASIS//DTD DocBook!' \
|
|
|
2fa604 |
-e 's!"http://www\.oasis-open\.org/docbook/xml/([[:digit:]])\.([[:digit:]])/docbookx\.dtd"!"docbook/sgml-dtd-\1.\2-1.0-30.1/docbook.dtd"!' \
|
|
|
2fa604 |
$SRC
|
|
|
2fa604 |
|
|
|
2fa604 |
# Prepare style final instance used in transformations.
|
|
|
8c13b6 |
docbook_prepareStyles "${DOCBOOK_STYLES_DIR}/docbook2pdf.dsl"
|
|
|
2fa604 |
|
|
|
7e4aec |
# Verify temporal directory and create it if doesn't exist.
|
|
|
7e4aec |
if [[ ! -d $TMPDIR ]];then
|
|
|
7e4aec |
mkdir $TMPDIR
|
|
|
7e4aec |
fi
|
|
|
7e4aec |
|
|
|
7e4aec |
# Move inside temporal directory.
|
|
|
7e4aec |
pushd $TMPDIR > /dev/null
|
|
|
7e4aec |
|
|
|
2fa604 |
# Create PDF format.
|
|
|
2fa604 |
docbook2pdf --dsl ${STYLE_INSTANCE_FINAL} ${SRC} &> /dev/null
|
|
|
2fa604 |
|
|
|
7e4aec |
# Verify `docbook2pdf' exit status and, if everything is ok, move
|
|
|
7e4aec |
# PDF file from temporal directory to its target location.
|
|
|
7e4aec |
if [[ $? -eq 0 ]];then
|
|
|
7e4aec |
mv $PDF $DST
|
|
|
7e4aec |
else
|
|
|
7e4aec |
cli_printMessage "`gettext "Cannot produce the PDF file."`" --as-error-line
|
|
|
7e4aec |
fi
|
|
|
7e4aec |
|
|
|
7e4aec |
# Return to where we initially were.
|
|
|
7e4aec |
popd > /dev/null
|
|
|
7e4aec |
|
|
|
2fa604 |
# Remove temporal directory and temporal style instances created.
|
|
|
7e4aec |
rm -r $TMPDIR
|
|
|
2fa604 |
rm ${STYLE_INSTANCE[*]}
|
|
|
2fa604 |
|
|
|
2fa604 |
}
|