XSL-FO 设置内联文本的默认最小宽度

发布于 2024-10-09 12:33:58 字数 983 浏览 3 评论 0原文

我正在编写 XSL-FO 文档,我想为一些内联元素设置最小宽度值。例如,在以下结构中

|    FirstName:         string1         LastName:         string2         |

,其中“string1”和“string2”是来自我的 XML 的数据,“|”表示左边框和右边框,

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

当各个人 (“John”、“Smith”、“” “Smith”、“SomeVery...”“Smith”)从 XML 加载。

基本上我需要这样的东西

<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>

,但这不起作用(最小宽度被忽略)。我在 fo:block 上尝试了 min-width,尝试了 inline-progression-dimension、block-progression-dimension、fo:table 的一些解决方法,但没有任何效果或者我做错了。我正在使用 Apache FOP 1.0。

有人可以帮忙吗? 提前致谢

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.

Can anyone help?
Thanks in advance

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

阳光下慵懒的猫 2024-10-16 12:33:58

我也遇到了这个问题,经过在网络上的一些搜索,我发现了一个解决方案:使用具有所需宽度的 fo:inline-container 和 fo:block 在您放置文本的位置内:

<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>

只需替换 widthselector 即可满足您的需求。此示例还包括我需要的底线,但它不是强制性的:如果不需要,只需从 fo:block 中删除 border-bottom 即可。请参阅如何获得内联 FO 的固定宽度? 了解原始内容解决方案和细节。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文