XQuery/XSL-FO Images

From Wikibooks, open books for an open world
Jump to navigation Jump to search


You want to enrich your documents with print quality images and charts etc.


We will use the fo:external-graphic primitive.

For example, to add an external image add a block to the XSL-FO:

    <fo:external-graphic src="https://tet/static/favicon.ico?r=2"/>


Vector Images[edit]

SVG is a standard way to describe graphical artwork as vectors. Recent eXist installations (>1.4) with the Apache FOP processor enabled can embed SVG data in the resulting PDF as vector art: just reference them via http redirection as they are not in the file system. See Generating PDF from XSL-FO files on how to activate the XSLFO feature.

 <fo:external-graphic src="http://localhost:8080/exist/rest/db/logo.svg"/>

PDF image extension[edit]

For the daring: there is an extension to apache fop, that provides for pdf-images: a method of placing pages of PDF files in the FOP output. Its the work of Jeremias Märki and available at his webspace.

$ wget http://www.jeremias-maerki.ch/download/fop/pdf-images/fop-pdf-images-2.0.0.SNAPSHOT-bin.tar.gz
$ tar xfz fop-pdf-images-2.0.0.SNAPSHOT-bin.tar.gz
$ cp fop-pdf-images-2.0.0.SNAPSHOT/*jar EXIST_HOME/lib/user

I had to restart exist to activate pdf-images support in fop. The fo syntax is the same as with SVG, a page-number can be specified after a hash sign in the URL.