[英]How to align text with the bottom of an XSL-FO block?
I am writing an XSLT script, that transforms an XML input document to an XSL-FO intermediate document, which get transformed into a PDF output document. 我正在编写一个XSLT脚本,该脚本将XML输入文档转换为XSL-FO中间文档,然后将其转换为PDF输出文档。
My fo:simple-page-master
exists out of three parts, a page header, body, and footer. 我的
fo:simple-page-master
由三部分组成,分别是页眉,正文和页脚。
<fo:layout-master-set>
<fo:simple-page-master master-name="a4-portrait"
page-width="210mm" page-height="297mm"
margin-top="0mm" margin-right="12mm" margin-bottom="0mm" margin-left="12mm">
<fo:region-body region-name="page-body" margin-top="20mm" margin-bottom="20mm"/>
<fo:region-before region-name="page-header" extent="20mm"/>
<fo:region-after region-name="page-footer" extent="20mm"/>
</fo:simple-page-master>
<fo:simple-page-master master-name="a4-landscape"
page-width="297mm" page-height="210mm"
margin-top="0mm" margin-right="12mm" margin-bottom="0mm" margin-left="12mm">
<fo:region-body region-name="page-body" margin-top="20mm" margin-bottom="20mm"/>
<fo:region-before region-name="page-header" extent="20mm"/>
<fo:region-after region-name="page-footer" extent="20mm"/>
</fo:simple-page-master>
</fo:layout-master-set>
Here is a simple hello world page: 这是一个简单的hello world页面:
<fo:page-sequence master-reference="a4-portrait">
<!-- Page header -->
<fo:static-content flow-name="page-header">
<fo:block vertical-align="text-bottom">Some headline in the page header</fo:block>
<fo:block vertical-align="text-bottom" border-bottom="0.25pt solid black"></fo:block>
</fo:static-content>
<!-- Page footer -->
<fo:static-content flow-name="page-footer">
<fo:block border-top="0.25pt solid black"></fo:block>
<fo:block>Page <fo:page-number/></fo:block>
</fo:static-content>
<!-- Page body -->
<fo:flow flow-name="page-body">
<fo:block>Hello World!</fo:block>
</fo:flow>
</fo:page-sequence>
As you can see, I already tried the vertical-align="text-bottom"
approach. 如您所见,我已经尝试过
vertical-align="text-bottom"
方法。 Unfortunately, the fo:block
-elements did not align to the bottom of the superordinate element. 不幸的是,
fo:block
-elements没有与上级元素的底部对齐。
How to write the XSLT in order to have the page-header
writes the text from bottom to top, instead of top-to-bottom? 如何编写XSLT以使
page-header
从下至上而不是从上至下写入文本?
XSLT 2.0, XPath 2.0, Apache FOP, Saxon-HE 9.8 XSLT 2.0,XPath 2.0,Apache FOP,Saxon-HE 9.8
Use display-align="after"
(see https://www.w3.org/TR/xsl11/#display-align ). 使用
display-align="after"
(请参阅https://www.w3.org/TR/xsl11/#display-align )。
display-align
applies to fo:region-before
(see https://www.w3.org/TR/xsl11/#fo_region-before ) as well as to the other regions, fo:block-container
, fo:external-graphic
, fo:instream-foreign-object
, fo:inline-container
, and fo:table-cell
. display-align
适用于fo:region-before
(请参阅https://www.w3.org/TR/xsl11/#fo_region-before )以及其他区域fo:block-container
, fo:external-graphic
, fo:instream-foreign-object
, fo:inline-container
和fo:table-cell
。
<fo:layout-master-set>
<fo:simple-page-master master-name="a4-portrait"
page-width="210mm" page-height="297mm"
margin-top="0mm" margin-right="12mm" margin-bottom="0mm" margin-left="12mm">
<fo:region-body region-name="page-body" margin-top="20mm" margin-bottom="20mm"/>
<fo:region-before region-name="page-header" extent="20mm" display-align="after"/>
<fo:region-after region-name="page-footer" extent="20mm"/>
</fo:simple-page-master>
<fo:simple-page-master master-name="a4-landscape"
page-width="297mm" page-height="210mm"
margin-top="0mm" margin-right="12mm" margin-bottom="0mm" margin-left="12mm">
<fo:region-body region-name="page-body" margin-top="20mm" margin-bottom="20mm"/>
<fo:region-before region-name="page-header" extent="20mm" display-align="after"/>
<fo:region-after region-name="page-footer" extent="20mm"/>
</fo:simple-page-master>
</fo:layout-master-set>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.