开发者

XSL-FO setting default minimum width for inline text

i am writing the XSL-FO document and i want to set min-width values for some inline elements. For example, in the following structure

|    FirstName:         string1         LastName:         string2         |

where "string1" and "string2" are data from my XML and "|"'s denotes left and right borders, i want the following results

|    FirstName:    John     LastName:   Smith                             |
|    FirstName:             LastName:   Smith                             |
|    FirstName: SomeVeryVeryLongFirstNameOfSomePerson  LastName:  Smith   |

when respective peoples ("John" "Smith", "" "Smith", "SomeVery..." "Smith") are loaded from XML.

Basicaly i need something like this

<fo:block> 
FirstName: <fo:inline min-width="50mm"> <xsl:value-of ...> </fo:inline> LastName: <fo:inline min-width="50mm"> <xsl:value-of ...> </fo:inline>
</fo:block>

but this isn't working (min-width is ignored). I tried min-width on fo:block, tried inline-progression-dimension, block-progression-dimension, some workaround with fo:table but nothing works or i'm doing it wrong. I'm using Apache FOP 1.0.

开发者_JAVA技巧

Can anyone help? Thanks in advance


I had this problem as well, and after some search on the web, I discovered a solution: use a fo:inline-container with the desired width and a fo:block inside where you put your text:

<fo:inline-container text-align="center" width="1cm">
  <fo:block border-bottom="0.5pt solid #000">
    <xsl:value-of select="your/xpath/selector"/>
  </fo:block>
</fo:inline-container>

Just replace the width and selector to match your needs. This example also includes a bottom line, which I needed, but it is not mandatory: just remove the border-bottom from fo:block if you don't need it. See How get fixed width for inline FO? for the original solution and details.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜