That does indeed get me the border, so much appreciated.
However, to tweak it just a little more... I had set up my images to be 90% of page width, like this:
<figure pgwide="1">
<title>some caption</title>
<mediaobject role="screenshot">
<imageobject>
<imagedata fileref="media/usrprf.export1.png" scalefit="1" align="center" width="90%"/>
</imageobject>
</mediaobject>
</figure>
...and your suggested example draws the border full page width. I tried fiddling with the template, like this :
<xsl:template match="mediaobject[@role='screenshot']">
<fo:block border="0.5pt solid black" width="90%">
<xsl:apply-imports/>
</fo:block>
</xsl:template>
...but the "90%" in the fo:block is apparently not used. So I have empty white borders either side, within the outline. I can of course make the images 100% wide but that scales them vertically too, using excessive paper area. Also, I'm a little uneasy about forcing 90% anyway on the template, I'd like it to stick to the image if possible.
What solutions should I consider?
Thanks,
Christopher
On 7 November 2012 20:12, Bob Stayton <> wrote:
Indeed, there is not an attribute-set for mediaobject
itself. I suspect that because there are so many attributes on the
graphics elements that must be supported, that another attribute-set might
introduce complicated interactions.
Fortunately, there is an easy way to get a border. Any
time you want to add features outside of an element itself, you can use
xsl:apply-imports. Try this:
<xsl:template match="mediaobject">
<fo:block border="0.5pt solid black">
<xsl:apply-imports/>
</fo:block>
</xsl:template>
This will add a fo:block container with a border, and put the
image inside it. Unless you have already customized the template matching
on mediaobject, the apply-imports will fall back to the original DocBook
template for it.
Bob Stayton
Sagehill Enterprises
From: Christopher BROWN
Sent: Wednesday, November 07, 2012 9:08 AM
To: DocBook Apps list
Subject: [docbook-apps] Adding a border around a DocBook
<imageobject> in PDF output
Hello,
I have some screenshots to include as part of a user manual I'm compiling
with DocBook, and several are on white backgrounds and contain mainly text, so
doesn't mix well with other text layout on the page. I tried to find out
how to add a border by regarding DocBook XSL documentation, specifically:
- http://www.sagehill.net/docbookxsl/BordersAndShading.html
- http://www.sagehill.net/docbookxsl/Graphics.html
..and the best I could do was following the second link, add a border
around the <figure> element (so it not only goes around the image, but
also around the <title>, leaving a lot of whitespace around the
image).
I then tried working out how add borders using the first link instead, so
that I'd only outline the image itself, but none
of <mediaobject>, <imageobject>, or <imagedata>
appear in the list of elements that recognize the attribute-sets referred to
there. A little further on, it says "you will want to find out where the
outer fo:block is output..." but I don't know what I'm looking for based on that
advice, nor how to find it, nor what to do with it (I'm a bit worried that I
might accidentally clobber something too by matching the template in a
higher-precedence customization layer).
Thanks,
Christopher