APACHE FOP DOCBOOK TO PDF
Docbook is easy to learn, easy to write, and does things other text Then you process file with Apache FOP, a Java application that. You should also take a look at the information about SVG support in FOP at the apache website: Bob Stayton. Apache™ FOP: General questions¶. What is Apache™ FOP?¶; .. Older DocBook style sheets generate fo:table-with-caption elements, so watch out.
|Published (Last):||22 February 2008|
|PDF File Size:||6.68 Mb|
|ePub File Size:||16.23 Mb|
|Price:||Free* [*Free Regsitration Required]|
This section will detail how to install the tools required to validate and process XML DocBook documents. The tools that will be installed are; a bunch of tools and libraries called ‘libxml’, Saxon and FOP.
The first will be used here to validate XML files and the latter two will be used to process XML files to produce other types of output. Another tool called a resolver will be installed to allow the tools to map links to files external to the computer being worked on to files local to the computer being worked on. This allows one to use the tools without an Internet connection and speeds up there execution.
The documentation for the installation is written under the assumption that the reader has some experience of installing software on computers and knows how to change the operating environment of the particular operating system they are using. Within this tutorial the primary purpose for installing the libxml C library will be to gain access the tools that come with it. The tools provide the means to validate and transform XML files.
The program xsltproc can be used to transform XML files. It is a program which uses XSLT.
To install libxml docbool a Windows machine one needs to download the Windows binaries and libraries. These can be obtained from http: The three links shown immediately above may be broken since it is docboook practice to remove old versions from a download page when they are obsoleted.
Some older versions are available in the directory oldreleases on that server, should one desire them. It is not apacue to extract the content of these zips entirely, instead the required functionality will be extracted. Create a suitable directory to contain the stuff that is about to be extracted.
For example, on my home machine. If I am running a Windows system I have a directory called c: Create a suitable directory to extract the desired content from the zips into. You might not use all the tools but they are worth having around in case you decide you need them.
These files are probably already installed on your system, as most modern distributions of these operating systems use XML processing for some of the more popular components. But you may wish to get the latest versions, in which case, goto ftp: There are gzipped tars and RPMs available, download whichever you prefer. A list of the latest files at the time of writing is shown below:.
The ftp directory also contains devel versions of the software, this is for people who want to develop with libxml. In this tutorial it is used to transform FO output produced by xsltproc into PDF which is a well known format considered by many to be aesthetically pleasing.
The Unix and Windows installation paths are very similar, the differences will be mentioned where appropriate. Download the latest version of the Fop application, from http: Download the zip or tar with bin as a substring of its name to some suitable location. On Windows, rename JimiProClasses. On Unix, rename JimiProClasses. The DocBook DTD Document Type Definition contains rules which specify the structure of a valid DocBook document, for example, the order that elements may appear and valid attributes etc.
DTD’s are especially useful when one wants to validate a document to check that it conforms to the DTD one claims it conforms to. Validation is beneficial because a valid document is less likely to break processing tools if a valid document does break a processing tool it is likely that the processing tool is broken and not the document.
Download the zipped archive, http: For example if I was running the Windows operating system I would unzip it to a directory like c: You might have noticed on the webpage or in the zip, other files apart from DTD files, these are auxiliary files and are necessary.
Some tools used for processing DocBook use the DTD at this location, this is no good when one wants to process a DocBook document on a computer that does not have Internet access or where accessing the Internet is undesirable.
To overcome the necessity to access the Internet to process DocBook documents one can use a catalog file. The DocBook zip that was just downloaded does actually contain it’s own catalog file catalog.
This does not seem to provide the desired functionality without modification. Instead of modifying that catalog file, create a new one called catalog in the docbook-xml Put the following content into it:.
The example above was taken from a Windows system, modify the value of the uri attribute to point to the location of the DTD on your system. On a Unix system this could be file: The processing tools must know where this catalog file is in order to use the functionality it provides. You could add similar entries to the catalog file shown above to map other DTDs you desire to use to local copies of their DTD’s.
The installation for Unix and Windows machines is the same. Download the latest stylesheets from http: If I was running a Windows system I would use c: The stylesheets are now ready to use.
The output produced by the stylesheets mentioned above is reasonable but the stylesheets mentioned above are a standard distribution and as a consequence seem to be designed to cater for the needs of the many, which is sensible, unfortunately. One may modify the stylesheets directly but more often one creates a customisation layer which imports the standard stylesheets and then one overrides specific aspects of the standard stylesheets or adds extra functionality within the customisation layer according to ones tastes.
I have created a customisation layer which looks good enough for standard applications and am offering it to download. This is particularly pertinent if you study at The University Of Birmingham because any documentation created by me there in DocBook uses this customisation layer, all the tutorials I have written conform to these stylesheets.
If you your documents to have the same style as the tutorials then use this customisation layer. It is probably worth downloading the customisation layer anyway so you can see how one goes about creating a customisation layer. Here is the zipped customisation layer: Unzip the zip to where you want the customisation layer to be situated, this could be within the stylesheets directory or in separate directory.
If you unzip it to the stylesheets directory the customisation layer will unzip into the directories commonfo and xhtml. If dodbook unzip aapche a separate directory these directories will be created.
Similarly, change the entry in customchunk. The advantage of unzipping the zip in the same location as the standard stylesheets is that the import links may be relative the import links can always be relative assuming the stylesheets are on the same machine, but for clarity if I am using a different directory for the customisation stylesheets I will make the import references absolute.
It rop become apparent how to use the customisation layer in the section on using the tools later. The provided customisations are listed below:. More information about customising stylesheets can be found at http: The –valid option specifies that xmllint should validate the document against the DTD and the –noout option specifies that no output should be produced if there are no errors, hence if the document being validated is valid, xmllint will exit silently.
If the document is invalid xmllint will output an error similar to this:. One can use the –loaddtd option to specify an external DTD to validate the file with. Also, the –nonet option can docnook useful to surpress fetching of DTDs files from the web if you find that your version dobcook this by default and you don’t want it too. The layout will accord to the XSL stylesheet specified.
How the PDF is created
The separate files will be given unique names that correspond to the different sections of the book, e. This will appache output as an XSL FO Formatting objectthis is an intermediate file type that can be used by other programs to generate other types of output, such as PDF. In order to execute this conversion you will need to have generated XSL FO output by using xsltproc or some other tool capable of doing so. This will generate a PDF file named according to the name provided as the second argument.
FOP will probably generate lots of warnings about un-implemented features whilst generating this output, this is normal and can dovbook ignored. Assume that a file called test. If you want to use the custom stylesheets you simply modify the stylesheet parameter so that it points to the custom stylesheet you want to use. Assuming an install of the customisation layer mentioned above in the same location as the standard stylesheets one ot generate XHTML output that conformed to the custom stylesheet for XHTML like this:.
For the ultimate reference guide see DocBook: A template for a DocBook article is shown below:. The output produced in the following examples was produced using a customisation of the stylesheets hence rop on systems not implementing the same customisations may differ.
The reference page for the para element can be found here: There is some debate about whether or not it is best to separate block elements from para elements, it is probably better to do so however because some processing systems have problems processing block elements within para elements. An example of a para t containing some inline elements is shown below:.
They are always sick. Docbooo vomit their gall and call it a newspaper. The reference page for the programlisting top can be found here: The programlisting element tl used to display information that should be output verbatim, that is, white space is significant. An example is shown below:.
The following entities are provided for special characters, they must always be used unless they are used in a section that has been marked as a CDATA section. The reference page for the screen element can be found here: Often one wants to illustrate the use of apachf program or a commandline, the screen element is intended to mark content up as text that a user would see on a computer screen.
The reference page for the ulink element can be found here: The reference page for itemizedlist is here: Itemized lists are standard bulleted lists and should be used where order of evaluation of the items of the list is not significant, ordered lists should be used where order of evaluation fot he items of the list are significant.
An example use of itemized list is shown below:. The reference page for orderedlist is here: Ordered lists are used to specify a sequence of steps of which the order of evaluation is significant.