OK, I thought that might be too simple. 8^)
If you want the border to match the image size, you'll need to
put the border on the fo:external-graphic element. Unfortunately, that
means you need to copy and customize the template named 'process.image' from
fo/graphics.xsl. That is currently a large template that handles a lot of
attributes. But adding your border attribute should be no
Sent: Wednesday, November 07, 2012 3:20 PM
Subject: Re: [docbook-apps] Adding a border around a DocBook
<imageobject> in PDF output
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:
...and your suggested example draws the border full page width. I
tried fiddling with the template, like this :
<fo:block border="0.5pt solid black"
...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?
On 7 November 2012 20:12, Bob Stayton <firstname.lastname@example.org>
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:
<fo:block border="0.5pt solid black">
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.
Sent: Wednesday, November 07, 2012 9:08 AM
Subject: [docbook-apps] Adding a border around a DocBook
<imageobject> in PDF output
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,
..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
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).