Graphics files come in many different formats, such as PNG, EPS, and JPEG. Unfortunately, there is no single graphics file format that meets all needs. HTML output files require bitmap graphics such as PNG or JPEG. Some browsers are beginning to accept SVG (scalable vector graphics), but support is not universal. XSL-FO processors generally accept bitmap graphics and vector graphics, but not all of them accept all formats.
If you are publishing only HTML output, then you just need to convert your pictures to one of the common bitmap formats such as PNG, GIF, or JPEG. All graphical browsers support these formats. But if you need to produce both HTML and print output from the same DocBook documents, then you may need more than one format. The formats you choose will depend on the type of illustration and the XSL-FO processor you use.
If you are using a screenshot, then a bitmap graphic can work for both HTML and print output. That's because the original screen itself was a bitmap display, so it will look good in HTML. It also will not improve or degrade when used in print. You still may want to scale the graphic differently for the two outputs.
If you are using a drawn illustration, you probably want to generate two graphic files derived from the same source drawing. Computer drawings use vector graphics, which produce smooth lines when reproduced at high resolution, such as in print. They can also be rendered at lower resolution if needed. But most HTML browsers do not accept vector graphics at all. So a typical solution is to produce two versions of the same picture, using a vector graphic format for print, and a bitmap format for HTML. All drawing programs provide several output formats to choose from, so check your software documentation to see which formats it can export to.
You also need to check the documentation of your XSL-FO processor to see what graphics file formats it supports. The following is a list as of this writing.
Table 18.1. XSL-FO processor supported graphics formats
PNG JPEG GIF TIFF BMP
SVG PDF EPS EMF WMF CGM
PNG JPEG GIF TIFF BMP
PNG JPEG GIF TIFF
SVG PDF EPS
An EPS graphic requires a PostScript interpreter to display its vector artwork. XSL-FO processors, PDF browsers and many printers do not contain PostScript interpreters, and will only display the low resolution bitmap image that is often embedded in an EPS file. Generally SVG gives better results with PDF and print output. If you have EPS graphics, you can convert them to SVG using Adobe Illustrator (not free) or Ghostscript (free).
Once you have determined which graphics formats are supported, you can convert your graphics to those formats and save the files with the appropriate filename extensions. Then you can create your
mediaobject elements with multiple formats. See the section “Stylesheet's selection process” to see how a given format is chosen.
What if you have a graphics file format that is supported in your output but is not supported by the stylesheets? For example, the Macromedia Flash Movie file format has a format of
SWF. This file format is supported in browsers with the Flash plugin.
To add a graphics format to the list of supported formats in the HTML stylesheet, copy the template named
html/graphics.xsl to your customization layer. Add your new format to the
xml:if statement, as in the following example:
<xsl:if test="$format = 'SVG'
or $format = 'PNG'
or $format = 'JPG'
or $format = 'JPEG'
or $format = 'linespecific'
or $format = 'GIF'
or $format = 'GIF87a'
or $format = 'GIF89a'
or $format = 'BMP'
or $format = 'SWF'">1</xsl:if>
Now you can add a
format="SWF" attribute to a
videodata element in your DocBook file. You will likely have to do some further customization of the
videodata template to output the correct HTML to support Flash movies, though.
You may also want to add a new graphics format when your XSL-FO processor upgrades to support a new format before the DocBook stylesheet distribution can catch up. In that case, copy the same template from the
fo/graphics.xsl stylesheet file to your customization layer and add the new format name.
|DocBook XSL: The Complete Guide - 4th Edition
|PDF version available
Copyright © 2002-2007 Sagehill Enterprises