+better. In the meantime, I have written my own program for making PostScript
+output -- see the previous section -- because the problems with xmlto/fop were
+sufficiently annoying.
+
+The PDF file that is produced by this process has one problem: the pages, as
+shown by acroread in its thumbnail display, are numbered sequentially from one
+to the end. Those numbers do not correspond with the page numbers of the body
+of the document, which makes finding a page from the index awkward. There is a
+facility in the PDF format to give pages appropriate "labels", but I cannot
+find a way of persuading fop to generate these. Fortunately, it is possibly to
+fix up the PDF to add page labels. I wrote a script called PageLabelPDF which
+does this. They are shown correctly by acroread and xpdf, but not by
+GhostScript (gv).
+
+
+THE PAGELABELPDF SCRIPT
+
+This script reads the standard input and writes the standard output. It is used
+to "tidy up" the PDF output that is produced by fop. It is not needed when
+PDF output is generated from SDoP's output using ps2pdf.
+
+The PageLabelPDF script searches for the PDF object that sets data in its
+"Catalog", and adds appropriate information about page labels. The number of
+front-matter pages (those before chapter 1) is hard-wired into this script as
+12 because I could not find a way of determining it automatically. As the
+current table of contents finishes near the top of the 11th page, there is
+plenty of room for expansion, so it is unlikely to be a problem.
+
+Having added data to the PDF file, the script then finds the xref table at the
+end of the file, and adjusts its entries to allow for the added text. This
+simple processing seems to be enough to generate a new, valid, PDF file.