You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-users@xmlgraphics.apache.org by JonathanHeard <jo...@jeh.org.uk> on 2008/06/24 09:12:10 UTC

Problem scaling 'backgrounds' using external-graphic inside absolute block-container

Hi All,
    This is only my first post on this forum and only my second day of
writing XSL:FO and using FOP - I am trying to produce a services catalogue
for a friend who runs a small training business and my design goal is to
maintain one copy of the catalogue in XML with both Web and PDF rendering.
I'm using Ken Holman's 'Definitive XSL-FO' as a reference as well as Michael
Key's "XSLT2.0 and XPath2.0 Programmer's Reference' to assist me with this.

I would very much like to be able to put a rounded rectangle box (or other
SVG frame) around blocks of text with varying size. I know that using
'background-image' has no support for scaling (unless I could afford XEP
which appears to have an extension for this)  - So I then though I was on to
a winner by using the following:

 40 <fo:block-container>
 41         <fo:block-container absolute-position="absolute" height="auto"
width="auto" border="1px solid blue">
 42         <fo:block border="2px solid green">
 43         <fo:external-graphic src="url(&quot;box3.svg&quot;)"
overflow="hidden" border="1px dashed black" content-height="   
scale-to-fit" width="100%" height="100%" content-width="scale-to-fit"
scaling="non-uniform" />
 44         </fo:block>
 45         </fo:block-container>
 46 
 47         <fo:block border="3px solid yellow">
 48         <xsl:apply-templates select="title"/>
 49         <xsl:apply-templates select="duration"/>
 50         <xsl:apply-templates select="coursedesc"/>
 51         </fo:block>
 52 
 53 </fo:block-container>
 
Bear in mind that I've been messing around a lot with the various properties
of each object, so my choices may not appear completely sane. Also the
'border' properties are there purely for me to see and debug the layout.
What I'm finding is that the blocks inserted by the templates 'title',
'duration' and 'coursedesc' force the block on line 47 to grow to the size
of the text, but because the block-container at line 41 is positioned
absolutely to allow it to sit behind the text content, it has no way of
basing its size on the quantity of text.

I'm really keen to know if anyone has a solution for this issue as it seems
a reasonably key function to be able to dynamically scale a background image
(I've hit exactly the same issue before with XHTML + CSS).

Any advice would be very much appreciated on any way that I might achieve
this effect.

Many Thanks
Jonathan
-- 
View this message in context: http://www.nabble.com/Problem-scaling-%27backgrounds%27-using-external-graphic-inside-absolute-block-container-tp18085205p18085205.html
Sent from the FOP - Users mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org


Re: Problem scaling 'backgrounds' using external-graphic inside absolute block-container

Posted by Andreas Delmelle <an...@telenet.be>.
On Jun 24, 2008, at 09:12, JonathanHeard wrote:

Hi

Apologies for the late reply

<snip />
> I would very much like to be able to put a rounded rectangle box  
> (or other
> SVG frame) around blocks of text with varying size. I know that using
> 'background-image' has no support for scaling (unless I could  
> afford XEP
> which appears to have an extension for this)  - So I then though I  
> was on to
> a winner by using the following:
>
>  40 <fo:block-container>
>  41         <fo:block-container absolute-position="absolute"  
> height="auto"
> width="auto" border="1px solid blue">
>  42         <fo:block border="2px solid green">
>  43         <fo:external-graphic src="url(&quot;box3.svg&quot;)"
> overflow="hidden" border="1px dashed black" content-height="
> scale-to-fit" width="100%" height="100%" content-width="scale-to-fit"
> scaling="non-uniform" />
>  44         </fo:block>
>  45         </fo:block-container>
>  46
>  47         <fo:block border="3px solid yellow">
>  48         <xsl:apply-templates select="title"/>
>  49         <xsl:apply-templates select="duration"/>
>  50         <xsl:apply-templates select="coursedesc"/>
>  51         </fo:block>
>  52
>  53 </fo:block-container>
>
> Bear in mind that I've been messing around a lot with the various  
> properties
> of each object, so my choices may not appear completely sane. Also the
> 'border' properties are there purely for me to see and debug the  
> layout.
> What I'm finding is that the blocks inserted by the templates 'title',
> 'duration' and 'coursedesc' force the block on line 47 to grow to  
> the size
> of the text, but because the block-container at line 41 is positioned
> absolutely to allow it to sit behind the text content, it has no  
> way of
> basing its size on the quantity of text.

One to achieve this, could be to use:
- one normal block-container (no absolute-position) to contain the whole
- one nested normal block-container with borders, surrounding the  
produced block
- four absolutely positioned block-containers containing the rounded  
corners

Both surrounding block-container's heights will grow to fit the block.
If the four block-containers for the corners then, are children of  
the first block-container (siblings to the b-c containing the block),  
their positions will be 'absolute' in that block-container, and you  
should be able to do something like:

<fo:block-container absolute-position="absolute" top="0" left="0">
...
<fo:block-container absolute-position="absolute" top="0" left="100%">
...
<fo:block-container absolute-position="absolute" top="100%" left="0">
...
<fo:block-container absolute-position="absolute" top="100%" left="100%">

This is roughly the idea. It will obviously still take some fiddling  
with those values to get the corners to align correctly with the  
borders of the block-container and overpaint the regular corners, but  
it definitely seems worth a shot.

HTH!

Cheers

Andreas

---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org