Blame Automation/Modules/Render/Docbook/docbook_setConversionXml2Pdf.sh

Alain Reguera Delgado 8f60cb
#!/bin/bash
Alain Reguera Delgado 8f60cb
#
Alain Reguera Delgado 8f60cb
# docbook_setConversionXml2Pdf.sh -- This function transforms DocBook
Alain Reguera Delgado 8f60cb
# files which have set the XML DTD in them.  To produce PDF from
Alain Reguera Delgado 8f60cb
# DocBook XML DTD, we need an XSLT engine (e.g., through `xsltproc'
Alain Reguera Delgado 8f60cb
# command) to produce formatting objects (FO), which then must be
Alain Reguera Delgado 8f60cb
# processed with an FO engine (e.g., through `pdfxmltex' command,
Alain Reguera Delgado 8f60cb
# which uses PassiveTex) to produce the PDF output.
Alain Reguera Delgado 8f60cb
#
Alain Reguera Delgado 8f60cb
# In this configuration and using default configuration settings, I've
Alain Reguera Delgado 8f60cb
# presented the following problems:
Alain Reguera Delgado 8f60cb
#
Alain Reguera Delgado 8f60cb
# 1. Something is wrong with headings. They are not expanded along the
Alain Reguera Delgado 8f60cb
# whole page-body. They seem to be rendered in a reduced width (1 inch
Alain Reguera Delgado 8f60cb
# approximately). This provokes the heading to be broken in a
Alain Reguera Delgado 8f60cb
# two-to-five letters column and sometimes it overlaps the sectioning
Alain Reguera Delgado 8f60cb
# titles (e.g., chapter, section). I tried to customize the value of
Alain Reguera Delgado 8f60cb
# `header.column.widths' and `page.margin.top' but it seems to be not
Alain Reguera Delgado 8f60cb
# there where I need to touch.
Alain Reguera Delgado 8f60cb
#
Alain Reguera Delgado 8f60cb
# 2. TOC's indentation is not rendered. Even the `toc.indent.width'
Alain Reguera Delgado 8f60cb
# property is set to 24 by default.
Alain Reguera Delgado 8f60cb
#
Alain Reguera Delgado 8f60cb
# 3. Inside lists, when items are more than one line, the indentation
Alain Reguera Delgado 8f60cb
# seems to work for the first line only.  All other lines in the same
Alain Reguera Delgado 8f60cb
# item are not indented and begin completely unaligned.
Alain Reguera Delgado 8f60cb
#
Alain Reguera Delgado 8f60cb
# 4. Long file paths near the end of page-body aren't hyphenated.
Alain Reguera Delgado 8f60cb
# Even the `hyphenate' property is set to `true' by default.
Alain Reguera Delgado 8f60cb
#
Alain Reguera Delgado 8f60cb
# In this configuration and using default configuration settings, I've
Alain Reguera Delgado 8f60cb
# presented the following advantages:
Alain Reguera Delgado 8f60cb
#
Alain Reguera Delgado 8f60cb
# 1. It is possible to produce localized PDF outputs through
Alain Reguera Delgado 8f60cb
# `xml2po', the default way of producing localized content inside
Alain Reguera Delgado 8f60cb
# the `centos-art.sh' script.
Alain Reguera Delgado 8f60cb
#
Alain Reguera Delgado 8f60cb
# To make the whole process transparent, a temporal directory is
Alain Reguera Delgado 8f60cb
# created for intermediate works and final files are moved then to
Alain Reguera Delgado 8f60cb
# their final location.
Alain Reguera Delgado 8f60cb
#
Alain Reguera Delgado 8f60cb
# Copyright (C) 2009-2013 The CentOS Project
Alain Reguera Delgado 8f60cb
#
Alain Reguera Delgado 8f60cb
# This program is free software; you can redistribute it and/or modify
Alain Reguera Delgado 8f60cb
# it under the terms of the GNU General Public License as published by
Alain Reguera Delgado 8f60cb
# the Free Software Foundation; either version 2 of the License, or (at
Alain Reguera Delgado 8f60cb
# your option) any later version.
Alain Reguera Delgado 8f60cb
#
Alain Reguera Delgado 8f60cb
# This program is distributed in the hope that it will be useful, but
Alain Reguera Delgado 8f60cb
# WITHOUT ANY WARRANTY; without even the implied warranty of
Alain Reguera Delgado 8f60cb
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Alain Reguera Delgado 8f60cb
# General Public License for more details.
Alain Reguera Delgado 8f60cb
#
Alain Reguera Delgado 8f60cb
# You should have received a copy of the GNU General Public License
Alain Reguera Delgado 8f60cb
# along with this program; if not, write to the Free Software
Alain Reguera Delgado 8f60cb
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
Alain Reguera Delgado 8f60cb
#
Alain Reguera Delgado 8f60cb
# ----------------------------------------------------------------------
Alain Reguera Delgado 8f60cb
# $Id$
Alain Reguera Delgado 8f60cb
# ----------------------------------------------------------------------
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
function docbook_setConversionXml2Pdf {
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
    # Print action message.
Alain Reguera Delgado 8f60cb
    cli_printMessage "${FILE}.pdf" --as-creating-line
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
    local -a STYLE_TEMPLATE
Alain Reguera Delgado 8f60cb
    local -a STYLE_INSTANCE
Alain Reguera Delgado 8f60cb
    local STYLE_INSTANCE_FINAL=''
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
    # Define absolute path to DocBook source file. This is the
Alain Reguera Delgado 8f60cb
    # repository documentation manual file where DOCTYPE and ENTITY
Alain Reguera Delgado 8f60cb
    # definition lines are set.
Alain Reguera Delgado 8f60cb
    local SRC=${INSTANCE}
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
    # Define absolute path to PDF target file. This is the final
Alain Reguera Delgado 8f60cb
    # location the PDF file produced as result of DocBook to PDF
Alain Reguera Delgado 8f60cb
    # transformation will be stored in.
Alain Reguera Delgado 8f60cb
    local DST="${FILE}.pdf"
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
    # Define file name of formatting object (.fo) file. This file is
Alain Reguera Delgado 8f60cb
    # an intermediate file needed to produced the PDF.
Alain Reguera Delgado 8f60cb
    local FO=$(echo ${INSTANCE} | sed -r 's/docbook$/fo/g')
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
    # Define file name of PDF file.  This is the file we were looking
Alain Reguera Delgado 8f60cb
    # for and the one moved, once produced.
Alain Reguera Delgado 8f60cb
    local PDF=$(echo ${INSTANCE} | sed -r 's/docbook$/pdf/g')
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
    # Prepare XSL final instances used in transformations.
Alain Reguera Delgado 8f60cb
    docbook_setStyles "${DOCBOOK_XSL}/docbook2fo.xsl"
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
    # Create link to `Images' directory. This is the directory where
Alain Reguera Delgado 8f60cb
    # images used by documentation are stored in. Be sure to remove
Alain Reguera Delgado 8f60cb
    # previous links first to prevent a recursive creation of links.
Alain Reguera Delgado 8f60cb
    ln -sf ${TCAR_WORKDIR}/Identity/Images/Webenv $(dirname ${INSTANCE})/Images
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
    # Create formatting object suppressing output from stderr.
Alain Reguera Delgado 8f60cb
    xsltproc --output ${FO} ${STYLE_INSTANCE_FINAL} ${SRC} 2> /dev/null
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
    # Create PDF format from formatting object. Because we are using
Alain Reguera Delgado 8f60cb
    # relative path to access `Images', it is necessary to move the
Alain Reguera Delgado 8f60cb
    # directory stack into the temporal directory where instance files
Alain Reguera Delgado 8f60cb
    # are created. Otherwise, the location used to load images will
Alain Reguera Delgado 8f60cb
    # fail.
Alain Reguera Delgado 8f60cb
    if [[ $? -eq 0 ]];then
Alain Reguera Delgado 8f60cb
        pushd $(dirname ${INSTANCE}) > /dev/null
Alain Reguera Delgado 8f60cb
        xmlto -o $(dirname ${FILE}) pdf ${FO}
Alain Reguera Delgado 8f60cb
        popd > /dev/null
Alain Reguera Delgado 8f60cb
    else 
Alain Reguera Delgado 8f60cb
        cli_printMessage "`gettext "Cannot produce the PDF file."`" --as-error-line
Alain Reguera Delgado 8f60cb
    fi
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
}