In addition to mzjn's answer, here's what I found that works great from a script (assuming the book is being built from a script). It works great and does not require you to fight Docbook on adding a figure or other layout elements. Thanks to Sid Steward for the page numbering suggestion.
You will need the following:
- book.pdf - your book with the Dockbook generated cover without graphics
- cover.pdf - the one page cover you want to use created with Microsoft Word, OpenOffice Writer, etc
- pdftk - toolkit for manipulating PDFs (http://www.pdflabs.com/tools/pdftk-the-pdf-toolkit/).
The following script will automate the 'fixup' of the book cover and numbering. Add them after the standard xsltproc
and fop
(or xep
) commands.
# xsltproc and fop commands omitted
...
# First, remove the Docbook cover
pdftk book.pdf cat 2-end output temp1.pdf
# Second, concatenate the desired cover and remaining book
pdftk cover.pdf temp1.pdf output temp2.pdf
# Third, clean up the book's output
pdftk temp2.pdf output book.pdf
# Cleanup temp files
rm temp1.pdf temp2.pdf
At this point, book.pdf
has the desired cover with images and other items such as a date, version, etc. But the page numbers are probably off.
The page numbers are off because Docbook numbers the cover as i
, the legal notice as ii
, the Table of Contents as iii
, iv
, iv
, etc. That is, they use Roman Numerals before the content and then Decimal numbering of 1
, 2
, 3
, etc. However, pdftk
does not accept numbering schemes at this time.
To fix the numbering scheme, use sed
to add the numbering scheme as follows. sed
will search for /Type /Catalog
. Once found, it will add a new line (\n&
). After the new line, the following is inserted to add the roman/decimal numbering: /PageLabels << /Nums [ 0 << /S /r >> 4 << /S /D >> ]
# Fix the page numbering
TMP_FILE=`mktemp /tmp/book.XXXXXXXXXX`
sed -e "s|/Type /Catalog|/Type /Catalog \n& /PageLabels << /Nums [ 0 << /S /r >> 4 << /S /D >> ] >>|" book.pdf > $TMP_FILE
mv $TMP_FILE book.pdf
0 << /S /r >>
means use lower case roman numerals starting at page 0 (its 0-based).
4 << /S /D >>
means use decimal numbers starting at page 5 (its 0-based). It should be changed to reflect page 1
of the book in question.