[英]XSL-FO: Adjust border-width based on text width
I am having trouble with XSL-FO using Apache FOP as a processor. 使用Apache FOP作为处理器的XSL-FO出现问题。 I have a simple stylesheet and already have set a round border to an fo:block-container.
我有一个简单的样式表,并且已经为fo:block-container设置了圆形边框。 The problem is: the text size is non-predictable given that the .fo file will be generated using a XSLT and a XML, so i need to tell FOP to adjust the border width according to the text width instead of applying the same width to all of the containers.
问题是:鉴于.fo文件将使用XSLT和XML生成,因此文本大小是不可预测的,因此我需要告诉FOP根据文本宽度调整边框宽度,而不是将相同的宽度应用于所有的容器。 Any ideas?
有任何想法吗?
In XSLT file:
在XSLT文件中:
<fo:block-container xsl:use-attribute-sets="right-side-itens">
<fo:block-container xsl:use-attribute-sets="rounded-borders">
<fo:block>
<xsl:value-of-select="./tagInsideXML/@attribute" />
<!-- qwertyuiopasdfghjkl -->
</fo:block>
</fo:block-container>
<fo:block-container>
` `
In the styles.xsl external file:
在styles.xsl外部文件中:
<xsl:attribute-set name="right-side-itens">
<xsl:attribute name="top">35px</xsl:attribute>
<xsl:attribute name="right">45px</xsl:attribute>
<xsl:attribute name="text-align">end</xsl:attribute>
<xsl:attribute name="font-size">10px</xsl:attribute>
<xsl:attribute name="height">10cm</xsl:attribute>
<xsl:attribute name="width">200px</xsl:attribute>
<xsl:attribute name="position">absolute</xsl:attribute>
</xsl:attribute-set>
<xsl:attribute-set name="rounded-borders">
<xsl:attribute name="margin-top">2px</xsl:attribute>
<xsl:attribute name="margin-right">1.8px</xsl:attribute>
<xsl:attribute name="padding-right">2px</xsl:attribute>
<xsl:attribute name="float">right</xsl:attribute>
<xsl:attribute name="line-height">18px</xsl:attribute>
<xsl:attribute name="font-size">8px</xsl:attribute>
<xsl:attribute name="border">solid 1.2px #000000</xsl:attribute>
<xsl:attribute name="fox:border-radius">6px</xsl:attribute>
<xsl:attribute name="position">relative</xsl:attribute>
<xsl:attribute name="overflow">visible</xsl:attribute>
</xsl:attribute-set>
Here is a sample image showing the desired output 这是显示所需输出的示例图像
A block-container usually has a fixed size, while a block can grow with its contents. 块容器通常具有固定的大小,而块可以随其内容而增长。 So I'd put an fo:block inside the container, and apply the border to that block.
因此,我将fo:block放入容器中,并将边框应用于该块。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.