XQuery/XSL-FO Images

MotivationEdit

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

MethodEdit

We will use the fo:external-graphic primitive.

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

 <fo:block>
    <fo:external-graphic src="http://www.uwe.ac.uk/includes/branding/better/engine/images/logo.gif"/>
 </fo:block>

execute

Vector ImagesEdit

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:block>
 <fo:external-graphic src="http://localhost:8080/exist/rest/db/logo.svg"/>
</fo:block>

PDF image extensionEdit

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.

Last modified on 25 February 2011, at 11:43